Hi.

One expansion possibility was this...
PHP Code:
$injector = new Injector();
$injector->registerAsSession(new Locator('MyInterface')); 
This makes the lifecycle orthogonal to the source. In particular it allows a class file searching algorithm to be added to the locator. The problem is how to fulfil a dependency from a session when the client of the class does not know which file to load...
PHP Code:
$injector = new Injector();
$injector->create('MyClass'); 
If it is the locator that is frozen in the session, rather than the object, then the locator can include the necessary file before unfreezing/instantiating the object. Of course this can happen behind the scenes as well, but allowing the user to write their own locators is an obvious flex point.

Meanwhile, all of these lifecycle choices are interesting to me...
PHP Code:
$injector->register('Class');
$injector->register(new Prototype());

$injector->registerAsSingleton('Class');
$injector->registerAsSingleton(new Class());

$injector->registerAsSession('Class');
$injector->registerAsSession(new Locator('Class'));
$injector->registerAsSession(new Locator(new Class()));

$injector->registerAsShared('Class');
$injector->registerAsShared(new Locator('Class'));
$injector->registerAsShared(new Locator(new Class())); 
Shared is shared memory in this case.

You could possibly have factories and persistence as well, but I like the idea of keeping things small. The real question for me is what is the smallest DI tool that is most useful for PHP. Pico seems to have a lot of namespace stuff that is just not needed for the single application slice that is a PHP script.

yours, Marcus