Hey Jurian,
This is an interesting discussion, but the bigger question is: to what end?
PHP (and other scripting languages) are largely successful b/c the
conceptual "application" is completely encapsulated inside of a web
request. This is also called a shared-nothing architecture. I have a
post on this:
http://ralphschindler.com/2010/05/06/phpundamentals-series-a-background-on-statics-part-1-on-statics
It sounds like you want a persistent application stack like Java or
.Net. This, in general, is not the "PHP Way" so to speak. Much of
PHP's ability to scale horizontally on demand is much due to it's
shared-nothing architecture.
More notes inline:
application instance into a session. My thoughts were it would only be
necessary to run the app ($app->run();).
The session is not a good place for putting a Zend\Application instance.
Reason being is that all the expense of creating the objects that make
up the Zend\App object graph are still gonna have to be serialized and
unserialized on each request. So, you are basically trading
__construct() on an object for a __wakeup() on an object to return it to
its live state.
This miserly failed because several files couldn't be loaded. I have not
investigated it further, but it looks to me it'd pretty cool if it was
possible.
Yep.. That is b/c you have created a chicken-and-egg problem. The
objects require application state to be set (like autoloaders and
include_paht settings), but now you've serialized that state into the
session. How do you expect to be able to load files when their
autoloader is serialized with the objects you want ot unserialize.
Is it an idea to look at Zend\Application for ZF2.0 to make this possible? It
would save a lot of resource: complete configuration, loading of config files and
so on are done once.
I think the bigger question here is how can we speed up an application
within the confines of PHP. I would say that right now we are doing
just that. We've identified the slowest parts of ZF1 based applications
as the autoloader, loading of files, and plugin loading. These key
pieces are being benchmarked and prototyped to be as fast as possible in
ZF2.
Furthermore, I think we can look at how ZF2 based applications play with
performance technologies like apc and zend optimizer to create a faster
ZF2 based MVC application.
Those are my thoughts off the top of my head.
-ralph