I've an application which stores some data in .php files in /library/ directory, eg. /library/config.php.

On my small old hosting library is at the include path, and so i managed do do require('config.php') anywhere without supplying the actual path.

Can there be any opportunity to auto prepend each .php file, to update the include path?

You will find some conditions:

  • the application doesn't follow front controller pattern
  • I've no use of php.ini
  • I've no immediate access to the dirs already contained in include_path
  • I can not use php_flag include_path
  • I can not use php_flag auto_prepend_file
  • some .php files get their own rules in .htaccess

Every other way than ctrl+H and replace <? with <? set_include_path…?

Edit:

Things I am searching for could be something such as:

RewriteCond %{REQUEST_FILENAME}  !-F
RewriteCond %{REQUEST_FILENAME}  !-d
RewriteRule (^*\.php)$ /library/$1 [NC,L]

Add [cde] towards the top of the file in which you require the library files to regulate the include path at runtime (you don't need to touch set_include_path() or php.ini files).

.htaccess

This prepends your library path to the present include path and helps make the files there directly available. You have to adjust set_include_path(dirname(__FILE__).'/library'.PATH_SEPARATOR.get_include_path()); to fit your library path (relative to the present file's location).

Is '/library' forbidden too? Which enables you to definitely customize the ini_set() too.