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.