I have a few things in various different files that get called from different places. I've been trying to use a $ROOT variable, but because I'm going from a few different files (index.php, view.php, admin/index.php etc) and don't have a bootstrap(or whatever that's called), I can't always get to $ROOT from things called by ajax etc..
if I set the include_path via htaccess somewhat like:
php_value include_path ".;C:\wamp\www\project\"
I assume that doesn't include subdirectories, and I would also have to add a line for each other directory where my files reside even if they're in C:\wamp\www\project\components
or C:\wamp\www\project\model
?
And do I add new lines or commas? I can't find any example online of using the htaccess to set include paths with multiple paths...
Alternately is there a way to get everything relating to my $ROOT variable and use absolute paths, and somehow have every file, even if they're in different places, reference that particular variable? (without having to make wholesale changes to all the files in the app?) That has the benefit of only needing to change on file in a server change/deployment, but I do not know how to start going about it!
thanks :)
I assume that doesn't include subdirectories,
Why didn't you try it? (it does include sub dirs)
I can't find any example online of using the htaccess to set include paths with multiple paths
? You've already provided one:
php_value include_path ".;C:\wamp\www\project\"
The paths are '.' and 'C:\wamp\www\project\'
(BTW its better practice to use '/' as the dir seperator - it avoids confusion over unix style escaping)
In a Windows environment, you would use semicolons to separate include paths like so:
php_value include_path ".;C:\wamp\www\project\;C:\wamp\www\project\components;C:\wamp\www\project\models"
But I'm not sure why you'd want to do so. Adding sub-directories opens up the possibility of file naming collisions. If you have, C:\wamp\www\project\components\example.php and C:\wamp\www\project\models\example.php, including both sub-directories in your include path will create ambiguity when you try to include either file. If you already have the project directory in your include path, you can already call anything inside it using a relative path. For instance:
<?php include 'components/example.php'; ?>
This would include C:\wamp\www\project\components\example.php and eliminate the chance of any file naming collisions.