eZ Community » Forums » Developer » Execute bin script outside eZ Publish...
expandshrink

Execute bin script outside eZ Publish root dir?

Execute bin script outside eZ Publish root dir?

Wednesday 29 July 2009 2:05:50 pm - 2 replies

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 happy.gif Emoticon

Thanks

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

Wednesday 29 July 2009 2:23:40 pm

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' );
}

Wednesday 29 July 2009 2:37:51 pm

Thanks !

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

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from