Execute bin script outside eZ Publish root dir?

Author Message

Bartek Modzelewski

Wednesday 29 July 2009 5:05:50 am

Hello,

I've got a big challenge: how to execute eZ Publish custom binary script from other directory than eZ Publish root? I've got the following file structure:

/
/ezpublish_root/ (contains typical ezpublish installation)
/sciprt.php

Now inside <i>script.php</i> i want to include ezpublish engne, i mean all $cli, $script etc .. that allows me to access all modules and stuff... In fact i need to access content module - just to get some data stored in eZContentObjets. Is it possible ?

I know that all calls to ezpublish must be done from eZ Publish root - that's what i'm doing for years, but now i try to do it out of ezpublish - it's just a try to integrate eZ Publish with other php software.

What should I do ? Is it possible somehow ? I have spent some time analyzing ezsys.php and other scrpts that initialize ezpublish, but general problem is with including classes. As we know aoutload/ezp_kernel.php contains path to libs, but there is still a lot of other places with includes. All my tries end with <i>An unexpected error has occurred. Please contact the webmaster.</i>

Can somebody help me ? Or tell me that it's just not possible to set some kind of "ez_base_path" ... so i will stop intregrating it this way, and find another :)

Thanks

P.S. One more thing: eZ Pulish must remain usable when accessing in browser http://mysite/ezpublish/

Baobaz
http://www.baobaz.com

Gaetano Giunta

Wednesday 29 July 2009 5:23:40 am

Try this as first lines of your script:

if ( isset( $_SERVER['REQUEST_METHOD'] ) )
{
    // this script is not meant to be accessed via the web!
    // note: ezscript class later does the same check, but after intializing a lot of stuff
    die();
}

// try to move to eZ Publish root dir if called in different dirs
if ( !file_exists( getcwd() . '/autoload.php' ) )
{
    $dir = dirname( __FILE__ );
    chdir( $dir . '/ezpublish_root' );
}

Principal Consultant International Business
Member of the Community Project Board

Bartek Modzelewski

Wednesday 29 July 2009 5:37:51 am

Thanks !

In fact I was thinking about it but ... "it's to simple, I will not work". So I haven't tried .. stupid me ;)

Baobaz
http://www.baobaz.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 22:24:26
Script start
Timing: Jan 30 2025 22:24:26
Module start 'layout'
Timing: Jan 30 2025 22:24:26
Module start 'content'
Timing: Jan 30 2025 22:24:26
Module end 'content'
Timing: Jan 30 2025 22:24:26
Script end

Main resources:

Total runtime0.0244 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.2656151.2266
Module start 'layout' 0.00540.0039 739.4922220.7188
Module start 'content' 0.00930.0135 960.2109997.8672
Module end 'content' 0.02280.0015 1,958.078133.9922
Script end 0.0243  1,992.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002610.8586140.0002
Check MTime0.00125.0266140.0001
Mysql Total
Database connection0.00072.856810.0007
Mysqli_queries0.002711.084730.0009
Looping result0.00000.048910.0000
Template Total0.00114.510.0011
Template load0.00083.455810.0008
Template processing0.00021.001210.0002
Override
Cache load0.00052.233410.0005
General
dbfile0.00031.161780.0000
String conversion0.00000.204540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs