loader

In my opinion all you are doing is adding another step a new user will have to 
perform when getting up and running with ZF2, and thus adding another layer of 
complexity, to what is already somthing that is hard to get a grip of.

Maybe add 2 implementations or show how both are used but with loader as 
default.

I understand composer has benefits in the long run but you are learning ZF2 , 
not composer.

Thanks
Daniel

Marco Pivetta <[email protected]> wrote:

Hi everybody!

tl;dr: ZF2: do you use composer or Zend\Loader? Simply reply with "loader"
or "composer" :)

I've been discussing on IRC about dropping the pre-configured Zend\Loader
instance in standard MVC applications (we're discussing that for ZF3).
Since I was asserting that most users do use composer for autoloading their
stuff, I got told to get proof of that - so please just drop me a line :)

The main idea is to move away from configuring autoloading per-library and
instead use composer to autoload everything. Here's how the config of a
composer.json file would look:

{
    "autoload": {
        "psr-0": {
            "MyLib": "path/to/my-lib"
        }
    }
}

Here's how it would look with Zend\Loader:

include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
Zend\Loader\AutoloaderFactory::factory(array(
    'Zend\Loader\StandardAutoloader' => array(
        'autoregister_zf' => true,
        'namespaces' => array(
            'MyLib' => "path/to/my-lib",
        ),
    )
));

The main difference here is that composer requires us to run `composer
dump-autoload` before being able to use `MyLib`

The idea is NOT about dropping Zend\Loader, but just removing the
initialization logic from the skeleton application.

If you also have thoughts except for your preference, please share!



Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

Reply via email to