I need a way to set/specify the include path at runtime based off a portion of the URL. Ie given http://someserver/baseinstalldir/toolna ... /pages.php I need to be able to set a specialized include path based on "instance" where I'll have several instances. Ideally there will only be one copy of all the pages.php (there are about 40 such files). I hate name-mangling (which is why I don't want to use GET style urls which could simplify this).
I've tried several options(listed below) all of them leave me feeling less than thrilled. I'm about to try Option 4, but was wondering if anyone here had any thoughts.
Option 1: store the base include path in a database, parse the url to retrieve it, always use absolute paths.
Pros: not webserver specific
Cons: requires a 2nd database connection per page view (each instance has its own DB, there is a central one for some management purposes, but its seldom connected to. Can be partially lessened by passing the path as a session variable, but you still get the hit on the first page load (which is the most common page hit by several orders of magnitude).
Option 2: make an htaccess file per directory
Pros: little additional server load, may use relative paths
Cons: requires a new file per instance, can't be combined with the last method for reducing the number of copies, requires AllowOverrides Options
Option 3: change hosting services to one that allows delgated dns, use instance.server/baseinstalldir/instance/pages.php, set include path in the vhost directive
Pros: slightly simpler url, little additional server load, single copy of files, may use relative paths
Cons: requires a hosting service that allows delegated DNS
Option 4: use url alias to redirect to the "reference install", the instance name is still in the url, so we can parse that to use.
Pros: low server load, one time change to the apache config
Cons: requires ability to add web aliases, must use absolute paths
Is there a better way: faking runtime include path
Moderator: General Moderators
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
http://www.php.net/manual/en/function.ini-alter.php
try doing something with that, since it returns the old setting on success, you can just store it in a var and change it back at the end of the script
try doing something with that, since it returns the old setting on success, you can just store it in a var and change it back at the end of the script