Include path
From struts4php
The include path of aPHP installation enables a developer to specify several directories, where libraries used in his application can be located. One of the best examples are the PEAR packages, that are usually installed in the so called PEAR directory, the has to be in each applications include path using PEAR packages.
The include path can be specified in many ways, mainly there are three.
php.ini
The first, and most popular way is to specify the include path in the php.ini file of your PHP installation. This means, that the include path is available in every application installed on your webserver that uses PHP, what sometimes is not desired, because if there are classes with the same names it can lead to namespace conflicts which sometimes can lead to complicated bugs or error messages.
This example shows the part of the php.ini file that set's the include path:
;;;;;;;;;;;;;;;;;;;;;;;;; ; Paths and Directories ; ;;;;;;;;;;;;;;;;;;;;;;;;; ; UNIX: "/path1:/path2" include_path = ".:/usr/local/lib/php"
This example set's the include path on a LINUX/UNIX system to the directory where the actual script is called from and to the directory /usr/local/lib/php. You can specify multiple directories by separating them with a colon. On a WINDOWS system the colon has to be replaced by a semicolon.
PHP function
Another popular way is to set the inlcude path with a PHP function like ini_set() or set_include_path(). This set's the include path to the directory or directories specified as parameter while invoking the function. The specified include path is only valid for the actual request and the script and it's includes that calls the function.
Therefore it is necessary to invoke one of these functions in every script where the external libraries are needed. This can be done by invoking the function on top of every page or write it once and include it in every script.
To include the passed directories, call the function on top of every script:
set_include_path(".:/usr/local/lib/php");
Apache's virtual host directive
One not very popular way is to specify the include path for a application in it's Apache virtual host directive. This set's the include path only for the application and may avoid namespace conflicts mentioned above.
To specify the include path for only one web application on your server add the following line to the virtual host directive:
php_value include_path ".:/usr/local/lib/php"
This line set's the include path on a LINUX/UNIX system to the directory where the actual script is called from and to the directory /usr/local/lib/php. You can specify multiple directories by separating them with a colon. On a WINDOWS system the colon has to be replaced by a semicolon.
