multiple set_include_path

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I tend to use the same scripts on different domains, but the path to the
library (which is where the real code/data is) might be in one of two
places, outside the webroot if I can set it there, or inside the webroot
if I can't

   so I've been hand editing the include path

so it's either




   Now, I'm not too worried about having a path that isn't visible from
the web, but I wonder  what precautions I need to take if my library is
say: $_SERVER['DOCUMENT_ROOT'] . '/library';

Largely what's in there is either classes, a config file with constants
and settings, and some serialized data.

   Also, it's a pain to have to change the paths

Any disadvantage to just having both:

or should I do something like:

if(! set_include_path('path_outside_web_root'){

  and how should I test for that, perhaps empty?

   Or should I not worry about this? Viewing these paths from a browser
gives me either nothing or an internal server error for the serialized data.


Re: multiple set_include_path

Jeff schreef:
Quoted text here. Click to load it

Hi Jeff,

Two remarks:
1) Isn't setting the includepath to the right directory part of
installing your application? Why do you want to automate it?
How are you delivering your application? Where do you put your lib?
I mean: if you place your lib somewhere, how much trouble can it be to
set the includepath to the right spot? 1 minute?

2) How bad is it when your files in the lib are accessable?
All my libfiles are PHP files (with a php extension) and they contain:
a) Class definitions
b) Functions
Both can be called directly by anybody without any effect. They won't
see the source, nor execute any code.
What are you putting in your libs?

But if you must do it the way you described, I would check if a file
exists in both positions the lib can be, and pick the first that holds
that file.

Erwin Moller

"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare

Site Timeline