|PHP set_inlude_path and include best practises||#1|
I am trying to run some PHP code on a standard XAMPP server. And put my stuff into the htdocs folder. The includes point to relative paths, But it does not work. Is there any best-practise for includes? The code has to run on machines of multiple developers.
posted date: 2008-12-27 06:49:00
|Re: PHP set_inlude_path and include best practises||#3|
Two directories down from where the file (or the file which included it) is running from.As for best practices there are only two advices i can give you.Use relative paths.If relative paths are giving you trouble, use an absolute path as a single static variable and the developers only change that one variable.
posted date: 2008-12-27 07:14:00
|Re: PHP set_inlude_path and include best practises||#4|
Relative path should work fine (warning: apache on windows, as I know, don't follow the simlinks, or whatever are called on that os).Maybe you should use the syntax (in order to avoid problem with different php versions)
and test the return value to see if all is ok.Turning to the best practices:To me setting an configuration directive into a script, expecially if project-wide, is wrong, or at least dangerous.A better practice is to put the directive into the .htaccess file in the directory that contains your php files project.Even better, it is faster, put the directives into the appropriate virtualhost section of your apache config. For develop, though, .htaccess is more flexible and therefore preferable.It should be something like this:php_value include_path ".:../..:<your path collection>"Doing this lets you share the php configuration w/o have fiddling with the ini_set directive in every php file you write.Not to mention that if you have a special file that needs a custom include_path, you can set it in the file and this will be evident to everyone at a very rapid glance.
posted date: 2008-12-27 07:50:00
|Re: PHP set_inlude_path and include best practises||#5|
See this related SO question about an include path strategy for more ideas.
posted date: 2008-12-27 12:45:00
|select page: « 1 »|