|
Posted by Rasmus Lerdorf on 01/06/05 18:27
On Thu, 6 Jan 2005, Josh Whiting wrote:
> > Anything you do in the MINIT hook is basically free, so it would be
> > trivial to load the data for the array from somewhere. Like a database,
> > an xml file, etc. So you wouldn't need to hardcode a complex array
> > structure in your MINIT hook, just have this generic little extension
> > that creates an array (or object) from some external source. To change
> > the data you would change that external source and restart your server,
> > or you could write a PHP function in your extension that forced a reload
> > with the caveat that each running httpd process would need to have that
> > function be called since your array/object lives in each process separately.
> >
> > If you ask really nicely one of the folks on the pecl-dev list might
> > just write this thing for you. Especially if you spec it out nicely and
> > think through how it should work.
> >
> > -Rasmus
>
> Call me crazy or ignorant, i'm both, but would it be possible to build
> an extension that, in its MINIT hook as you suggest, actually runs a
> separate PHP script that contains global definitions, then makes those
> definitions available to later scripts? this is basically my original
> desire of having a one-time, persistent global include for each apache
> process. i realize you suggest pulling array data from a source like a
> DB or XML file, which would be a 90% solution for me, but the next step
> (a PHP script) just seemed logical/exciting...
>
> i realize i'm reaching with this, and it implies a conundrum (how does
> an extension run a PHP script if PHP hasn't fully started yet) but this
> kind of thing is just what makes me go and learn new things (C, php/zend
> internals) and I just might try to do it if it was feasible, for the fun
> of it, because it could be useful to lots of people, even if it took me
> a year or two to pull off.
>
> alas, this is a question for the pecl-dev list.
>
> (the mental gears are churning...)
The apache-hooks SAPI can do this, although when I initially wrote it
nobody seemed interested. George fixed it/rewrote it to work much better,
but nobody was interested in his version either, so the current
implementation isn't up to date anymore. The problem was likely that
people really didn't understand how to use it and it is a rather unsafe
thing to let PHP scripts fiddle with all the various Apache request hooks.
You can really toast your server that way. A simple generic data loading
extension is something people will be able to understand and they are
unlikely to destroy their server with it.
-Rasmus
Navigation:
[Reply to this message]
|