Forums / Developer / Initializing eZ when not using CLI or Exponential

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Initializing eZ when not using CLI or Exponential

Author Message

Atle Pedersen

Monday 14 May 2007 6:54:26 am

Hi,

I need to get some data from the eZ database using for example:
$node =& eZContentObjectTreeNode::fetch( 2 );

However I am using a php program that is called directly from apache, and not from CLI nor from within Exponential.

My guess is that I need to to some initializing of some sorts, but I don't know what.

Can anyone point me in the right direction?

Michael Maclean

Tuesday 15 May 2007 2:56:41 am

The minimum that I've managed to get away with so far has been:

include_once('lib/ezutils/classes/ezini.php');
include_once('lib/ezutils/classes/ezsys.php');
include_once('lib/ezdb/classes/ezdb.php');
include_once('access.php');
include_once( "lib/ezutils/classes/ezdebugsetting.php" );
include_once( "kernel/classes/ezcontentobjecttreenode.php" );

/*!
  Dummy function, required by some scripts in Exponential.
*/
function eZUpdateDebugSettings( $useDebug = null )
{
}

$ini = eZINI::instance();

// This will get the default siteaccess name, or you can hard code it if you want
// $siteaccess = 'accessname';
$siteaccess = $ini->variable( 'SiteSettings', 'DefaultAccess' );
$access = array( 'name' => $siteaccess, 'type' => EZ_ACCESS_TYPE_DEFAULT );
$access = changeAccess( $access );

$node = eZContentObjectTreeNode::fetch( 2 );
var_dump($node);

You will probably need to change the paths to the includes.

eZpedia community documentation project | http://ezpedia.org

Atle Pedersen

Thursday 24 May 2007 6:23:59 am

Thank you Michael, this was excatly what I needed.