I am trying to convert my beta DI code to version ZF2. Right now, I am falling at the very beginning, and there seems to be no documentation about injecting material into controllers, which makes me think that it is not normal to have dependencies in the controller?
Right now I'm just doing var_dump('blah');exit; to try to run some code ... I tried a few things and now I expected this to work:
module.config.php
'controllers' => array( 'invokables' => array( 'indexController' => 'Application\Controller\IndexController', ) )
module.php
public function getControllerConfig() { return array( 'factories' => array( 'indexController' => function(ControllerManager $cm) { var_dump('blah');exit; }, ), ); }
Nothing is happening right now, and it's rather unpleasant ... I read something about creating factories for each controller, but I have 33, and I find it completely insane and stupid ...?
What I'm trying to implement is stuff like userMapper for capturing / saving users. Thus, registerAction creates a user in the database using userMapper, and when you try to log in, it uses userMapper to check if the user is there, etc.
source share