bombusbee.com Logo bombusbee.com
PHP Tricks

November 30, 2001

::: Global include directory :::
Page 2 of 3 ::: 1 2 3 ::: view printable
In my previous article on Forcing Users Through index.php, I talk about the use of an auto_prepend_file. That sets a file to be run before anything else when a PHP request is run. Just like it is the auto_append_file, which gets run, of course, at the end of the request. Set this like so:

  
php_value auto_prepend_file Application.php
#php_value auto_append_file /path/to/file


One trick that I just recently figured out was that you can set a default include directory. This is much like the concept of a central Custom Tags directory for ColdFusion. When you set a centrally located include directory, when you include() a file in your script, PHP will look in the designated directory for the requested file. When you set this value, be sure to include the current directory in the list of include directories (i.e. "." means this directory, just like ".." means the parent directory):

  
php_value include_path .:/home/site/includes


To break that down, the ":" is a delimiter, so "." says to look in the current directory first, and "/home/site/includes" says to look in that absolute directory next for the requested include. In a Windows environment, use a ";" as a delimiter, so you can use drive letters for absolute directories, like so:

  
php_value include_path .;c:\home\site\includes


Putting the previous two tricks together solves the problem I brought up in the article on Forcing Users Through index.php. If you use this central include directory, you can put your Application.php file in there, and your auto_prepend_file will look for that file as if it were include()-ed before anything else was run. No need to name the auto_prepend_file absolutely — just place it in your global include directory!


<< Turning off register_globals Magic session maintenance! >>

© 2000-2008 bombusbee.com, all rights reserved


Fusebox inside   Powered by PHP   Powered by MySQL   Powered by Apache   SourceForge: support opensource software

Fusebox: Developing Coldfusion Applications

Discovering Fusebox 3 for ColdFusion

Get the new Fusebox books!