I am fairly far into a project, and am having trouble having everything included properly.
I have several files in different directories that need to include the same files, but since some are called via ajax or via includes in different situations, there path varies. I had a php_include path set up via .htaccess, but the testing server I need things set up doesn’t run with php commands in the .htaccess! I am trying to figure out a quick way of roping everything together.
I have multiple files all including the same ‘project’ file that in turn includes functions, etc. I have a $ROOT variable set-up to store the absolute path of my directories, but that’s not usable in includes without mucking with the php.ini, which I can’t do easily, and it’s included afterwards anyway.
I know a little bit about bootstrapping, and I would love to route everything through htaccess, but I don’t really have a concept of how to implement something like that really quickly and easily (and would that work for files called through ajax?)
I can’t rely on server_document_root because it may need to reside in a subdirectory.
This is not class based, but has value objects for database stuff.. there’s the main home.php, view.php etc in the root directory, then a program/ directory with the main scripts and value objects, then utilities and components folders that contain miniature view type classes.
I would redo everything if I had time, but right now I’m trying to figure out a way to have everything just work (preferably without dumping everything into one folder :p)
In
home.php, orview.phpinclude your “main” file, this will include the rest of your app.Its ok if
home.phporview.phpare in some other directory, just do whatever you need to do in that file to loadbase.phpsomething like this will work the same:Then in
base.phpThe
__FILE__is the full path to the current file,dirnamegets its directory, then you can write all of your includes/requires relative to the location ofbase.php.I hope this helps point you in a helpful direction.