|
Forcing Users Through index.php
November 27, 2001
The example shown on the previous page will indeed work just fine. You can stop here if it has solved your problem. However, there are some ways to fine tune this concept and make your coding a little simpler.
The first "problem" with the previous example is that if you have subdirectories, as we commonly do in Fusebox, you will have to include an Application.php file for every subdirectory of the main application. That is just fine if that is the way you want to do things, but it can get a little unwieldy, especially if you want to make a change to the way your Application.php file works. The solution I have used for that problem is to locate a single Application.php file by using an absolute path to it in the .htaccess file:
| |
php_value auto_prepend_file /home/htdocs/Application.php
|
That way you only have to maintain one file. If you do have a non-Fusebox subdirectoy, you can override the auto_prepend_file setting in that directory's .htaccess file.
(added 11/30/2001) You can also avoid this problem by setting a global include directory, and placing the Application.php file in there. Then you will not have to put an Application.php file in every directory, nor will you have to set the path to it absolutely. In fact, if you want to mimic the functionality of Application.cfm from ColdFusion, set the auto_prepend_file to "Application.php", and set your global include directory to your application's root. There are more details in the new PHP Tricks article from November 30, 2001.
Is this the only way to force people through the index? No, not really...
|