Solution to problems with PHP set_include_path
April 18th, 2009 (worufu)Anybody using the Zend Framework (or any other php script using set_include_path() ) might already have experienced problems with set_include_path() at one time or another.
Most Zend Framework implementations (including implementations from the reference guide) are using set_include_path() within the bootloader.php file to setup the correct include path for the Zend Framework. The nice thing is that by doing so you’ll just have to write e.g. require_once(‘Zend/View.php’) for including Zend Framework classes or not even that by just using the great Autoloader feature. In a perfect environment setup you’ll just have to instantiate a new object of any Zend Framework class and it gets loaded automatically (you don’t even have to require/include any additional file as the Autoloader loads classes automatically from within the specified include path). Additionally you extend the include path to a library folder, etc.
Now it happens that in some mysterious server setups you cannot override the pre-defined include path. Neither set_include_path() nor ini_set(‘include_path’, ‘/path/:.’) have any effect on what get_include_path() is holding for you.
In such a case it might help to check you apache config which also can set the php include path. If it is set within the apache config you are out of luck. You simply cannot override it by script anymore. Same applies to setting the include path from within .htaccess. That also disables the ability to set the include path by script.
One thing I have not evaluated yet practically (but which I hope to be accurate in theory) is that you still can pre-define the value within apache config and .htaccess and at the same time allow override by script: just use php_value instead of php_admin_value when pre-defining php values.
