-- lode <[email protected]> wrote (on Monday, 17 September 2012, 04:36 AM -0700): > I'm playing around with the flexibility of the modules. > > If I make a controller Ns\Controller\Index > > Then in the module config I get something like > > 'controllers' => array( > 'invokables' => array( > 'Ns\Controller\Index' => 'Ns\Controller\Index', > ), > ), > > If I remove the seamingly nonsens alias I get exception: > Zend\ServiceManager\ServiceManager::get was unable to fetch or create an > instance for Ns\Controller\Index > > I understand the aliasing from IndexController => Index for routing > purposes. > > Wouldn't it be much nicer if the service manager could just locate this > controller without it having to be defined in the config?
Nicer, yes -- until you define a route that allows dynamically specifying the "controller" parameter, and somebody specifies a class that has unwelcome side effects during instantiation. We chose to require explicitly defining what controllers may be pulled from the ControllerManager for security reasons -- there were very real proofs of concept that demonstrated the exact scenario I outlined in the previous paragraph. By being explicit, the framework is safe by default; you as a developer can always choose to use an abstract factory or alternate ControllerManager implementation to get around it, but such changes will affect only your project, not all ZF users. -- Matthew Weier O'Phinney Project Lead | [email protected] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- List: [email protected] Info: http://framework.zend.com/archives Unsubscribe: [email protected]
