Re: [phplib-users] proper way to run several instances of a phplib-app
Brought to you by:
nhruby,
richardarcher
From: patrick <pm...@s-...> - 2006-10-05 15:13:35
|
Marko Kaening wrote: > Hi folks, > > pretty quiet on this list. :) But perhaps it is simply because phplib > simply works. > > I met with my application a new requirement recently. I essentially want > to run the same application with different local.inc's. This makes sure > that every instance has its own session handling and user management, so > that both instances do not see and touch each other's databases. > > Up to now I simply duplicate the whole app directory, modify the local.inc > and point the browser to that source directory. > > Anybody knows a cleverer way to implement this without the need to copy > the whole source directory each time I set up a new instance? I thought > about am additional cookie (or get parameter as fall-back) or so, which > does the selection of the corresponding database-set specifiable in > various local.inc's... But I have no idea how to implement that > properly... > > Any hint for me from the community? > > Marko How do you determine which local goes with which instance? I do something like this for testing: In index.php: switch ($_SERVER['HTTP_HOST']) { case 'www.example.org': case 'example.org': default: include_once($_SERVER['DOCUMENT_ROOT'] . '/example/etc/example.php'); $protocol = 'https://'; break; case 'dev.example.org': include_once($_SERVER['DOCUMENT_ROOT'] . '/example/etc/example_test.php'); $protocol = 'http://'; break; } Then, in example.php (or where ever, really) you can set different DB credentials for session repository, cookies, etc. Not sure if this helps you. It's obviously predicated on different entry URLs. But I imagine you could do something with pseudo-random hashes each access... /patrick |