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.php
atsrc/YourBundle/Controller
folder. And put class with nameYourControllerNameController
into 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\Controller
In 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/Controller
folder and will generate new route for any method in any class in any file that will have annotation@Route
: