This is a discussion on help with php.ini include_path? within the PHP Language forums, part of the PHP Programming Forums category; I'm attempting to integrate some PayPalPro supplied modules which come with their own directory structure. I've installed this &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm attempting to integrate some PayPalPro supplied modules which come with
their own directory structure. I've installed this "directory" into my common "working" includes directory. However, because the supplied code uses so many levels of includes PHP is not finding the referenced included functions. Heres an example: my own working includes: /cgi-bin/includes and I've installed the PayPalPro supplied stuff into that directory which then constructs: /cgi-bin/includes/PayPal/ /cgi-bin/includes/PayPal/Stuff/ /cgi-bin/includes/PayPal/Stuff/more_stuff/ /cgi-bin/includes/PayPal/Stuff/more_stuff/etc/ and so on. When I use "include_once("module_name.php"); in my program the compiler FINDS the module but the module itself then includes more items from further on down the tree. I've added the recursed directories to my php.ini include_paths directive but is this really necessary? Does one have to include each and every directory explicitly or is there a method to define "recurse from this directory down" somewhere? I've searched the docs (books, bibles, groups, php.net, etc) and cannot seem to come up with any other way. Please tell me I'm crazy and that there is a more reasonable way to accomplish this? Advice, help appreciated! Bob |
|
|||
|
bobmct wrote:
> I'm attempting to integrate some PayPalPro supplied modules which come > with > their own directory structure. I've installed this "directory" into my > common "working" includes directory. > <snip> > > /cgi-bin/includes/PayPal/ > /cgi-bin/includes/PayPal/Stuff/ > /cgi-bin/includes/PayPal/Stuff/more_stuff/ > /cgi-bin/includes/PayPal/Stuff/more_stuff/etc/ > > and so on. > The first thing to note is that, if possible you shouldn't put include files within the document root. But lets assume you don't have a choice. So your include path has /cgi-bin/includes So if we assume there are some files as follows: /cgi-bin/includes/PayPal/pp.inc /cgi-bin/includes/PayPal/Stuff/cc.inc then you can certainly write your script as: <?php include("PayPal/pp.inc"); However as you may have noticed, this won't work too well if pp.inc contains: include("stuff/cc.inc"); (side note if pp.inc contains 'include("cc.inc");' then walk away carefully deleting all files as you go). Simplest solution is to move all the files up a dir: cd Paypal mv * .. One other solution is to add /cgi-bin/includes/PayPal to your include path. Another way is to rewrite the files to use relative addressing, e.g. in pp.inc: $mydir=dirname(__FILE__); $include_file=$mydir . "/stuff/pp.inc"; include($include_file); HTH C. |
|
|||
|
Colin McKinnon wrote:
> bobmct wrote: > >> I'm attempting to integrate some PayPalPro supplied modules which come >> with >> their own directory structure. I've installed this "directory" into my >> common "working" includes directory. >> > <snip> >> >> /cgi-bin/includes/PayPal/ >> /cgi-bin/includes/PayPal/Stuff/ >> /cgi-bin/includes/PayPal/Stuff/more_stuff/ >> /cgi-bin/includes/PayPal/Stuff/more_stuff/etc/ >> >> and so on. >> > > The first thing to note is that, if possible you shouldn't put include > files within the document root. But lets assume you don't have a choice. > > So your include path has > /cgi-bin/includes > > So if we assume there are some files as follows: > > /cgi-bin/includes/PayPal/pp.inc > /cgi-bin/includes/PayPal/Stuff/cc.inc > > then you can certainly write your script as: > > <?php > include("PayPal/pp.inc"); > > However as you may have noticed, this won't work too well if pp.inc > contains: > include("stuff/cc.inc"); > > (side note if pp.inc contains 'include("cc.inc");' then walk away > carefully deleting all files as you go). > > Simplest solution is to move all the files up a dir: > > cd Paypal > mv * .. > > One other solution is to add /cgi-bin/includes/PayPal to your include > path. > > Another way is to rewrite the files to use relative addressing, e.g. in > pp.inc: > > $mydir=dirname(__FILE__); > $include_file=$mydir . "/stuff/pp.inc"; > include($include_file); > > HTH > > C. C, Thanks for the short explanation. The PayPal directory structure is exactly WHAT is supplied in the PayPal SDK and a look through their modules seems to indicate that the structure must be maintained although their top level "paypal" can be relative. I was HOPING that php includes would be recursive but it appears not. What I actually had to do was build my php.ini's include_path to include each and every directory in the PayPal structure, each with a fully qualified patch (what a real pain). Creates for a very long path. There's GOT to be a better and/or another way. Thanks, Bob |