In which files do we need to make changes in order to add a new controller in Module and call it through URL.
Is there a way in which we add a new controller file and call it through url without changing any other configuration files.
As it will be very tedious to make changes in configuration files on every add or edit in controller files.
From Zend Framework 2 reference
src : http://framework.zend.com/manual/2.0/en/modules/zend.mvc.quick-start.html#create-a-route
As sayed by Matthew Weier O'Phinney .
To create a new controller, you have at least to
controllers.invokables
entry in your module'smodule.config.php
.There's no way around these three simple steps. I don't see why it should be a problem to adapt the
module.config.php
when you add a controller -- that's what config files are for. Including opening, saving und closing, this takes approx. 10-15 seconds. You aren't going to create hundreds of controllers, are you?I am adding a little clarification to what Daniel said on "make sure you've got a matching route that satisfies your purpose...". For my purpose I was trying to accommodate routes to module/Application/src/Application/Controller/IndexController.php and module/Application/src/Application/Controller/ProfileController.php, however I struggled to resolve anything to my ProfileController. It was also not clear if ZF2 could accommodate multiple Controllers in a single module. I thought surely it must and it does! Given the two above controllers this is how I crafted my 'router' array inside module/Application/config/module.config.php.
Also this is what my 'controllers' invokables looks like in modules.config.php following success.