views:

275

answers:

2
+1  A: 

I may be mistaken (it's late) but aren't you just trying to do some form of caching? Regardless, the FastCGI interface seems to be fairly well defined. So, it should be possible to do whatever you want, fairly easily.

sybreon
Well, it could be that caching is the way to go with PHP. What I'm really looking for is to have PHP code loaded _and_ initiliazed in memory. Imagine a framework with a lot of objects. As it's now it seems to me that all code needs to be initialized for every request. (Even if this process may be sped up by caching the bytecode etc.) I'd like to be able to write a framwork that has the ability to setup everything once. I guess :) This might no make sense in the face of clever PHP caching mechanisms. I don't know.
0scar
But wouldn't this take up much more memory, which would also slow things down?
sybreon
Well in practice yes, since the heap would probably grow larger and larger with every request. But theoretically, no. You're loading the same things. You just do it before a request, once, instead of on every request.
0scar
"FastCGI interface seems to be fairly well defined. So, it should be possible to do whatever you want, fairly easily" .. great! So how do you do it?
0scar
Since it's based of CGI I guess it's something like this. You need to provide the PHP script with some environment variables, and then read the PHP output off stdin. Then, do your magic and pass it on to the web-server.
sybreon
A: 

You can not do it in PHP for PHP, you can do it in C for cgi-sapi but you probably want to use APC instead.

jpic
Are you absolutely sure of this? Why not?
0scar
My bad, i meant fastcgi sapi actually.@Oscar: Are you asking why doesn't it do what you expect? Check out http://php.net/apc it solves your needs.
jpic