I am unable to create Controllers through the Command line. Does anyone know how can I manually create controllers for my Symfony2 project?
What files I need to update?
I am unable to create Controllers through the Command line. Does anyone know how can I manually create controllers for my Symfony2 project?
What files I need to update?
You should create file
YourControllerNameController.phpatsrc/YourBundle/Controllerfolder. And put class with nameYourControllerNameControllerinto this file. Also be assured that you wrote right namespace according to PSR-0.If you create controller as a service you can define it as a service and have no problem.
If you want create standard controller that are not registered at service container you could extend your class from
Symfony\Bundle\FrameworkBundle\Controller\ControllerIn both cases you need also define route for your actions. The easiest way would be to define one route with annotation type. It will generate routes automatically based on your annotations related to actions:
It will scan your
src/YourBundle/Controllerfolder and will generate new route for any method in any class in any file that will have annotation@Route: