Sunday 27 November 2005 11:03:00 pm
After installation of the eZ Components, either via PEAR Installer, downloading of the archives, or getting them from SVN, you need to do a bit of configuration:
The PHP include path should point to the directory where the eZ Components reside. You can either set it in the php.ini configuration file or with the set_include_path() function from within your script.
If you installed the components with the PEAR installer, then in most cases you do not have to make any changes as PHP's include path will already cover the default
/usr/local/lib/php
into which the PEAR installer will install the eZ Components. In case it is different, please set it at the top of your script with:
<?php <a href="http://www.php.net/set_include_path" mce_href="http://www.php.net/set_include_path">set_include_path</a>("/path/to/root/pear/directory:" . <a href="http://www.php.net/ini_get" mce_href="http://www.php.net/ini_get">ini_get</a>( "include_path")); ?>
In case you downloaded a bundle, or checked out the components from SVN, set the include path to the root of the checked out archive. For example with:
<?php <a href="http://www.php.net/set_include_path" mce_href="http://www.php.net/set_include_path">set_include_path</a><span>("/path/to/ezcomponents-1.0rc1:" . <a href="http://www.php.net/ini_get" mce_href="http://www.php.net/ini_get">ini_get</a>( "include_path")); ?>
The PHP classes of the eZ Components can be conveniently used from within your PHP script. You don't have to use any require or include statements for any of the eZ Components classes that you use, this is because of the integrated autoload mechanism which can locate the classes for you when you instantiate or use them otherwise.
Therefore, you should add the following code on top of your PHP script:
<?php require_once "Base/base.php"; // dependent on installation method, see below function __autoload( $className ){ ezcBase::autoload($className ); } // your code here ?>
The require_once statement is different depending on the installation method:
PEAR Installer:
ezc/Base/base.php
Downloaded bundle:
Base/src/base.php
SVN:
Base/src/base.php
Do not forget to add these lines, otherwise the eZ Components will not function properly, because all of them use the autoload internally.