I am working on a project where I have about 98 controllers. We have decided to migrate this project to Symfony. I have been able to create a custom Bundle called "mdBundle".
It gets registered and I able to access the controller without any issue if I use type: annotation in the routing.yml file.
However because we have so many controllers it will take forever to create the anotations in the actions. Therefore I am trying to come up with a way that my routing.yml can handle any request and execute the controller requested.
Right now my routing.yml looks like this:
mdRoute:
path: /{_controller}/{_action}/
defaults: { _controller: mdBundle:_controller:_action }
My Controller(DefaultController.php)
is like this:
namespace mdBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class DefaultController extends Controller
{
public function indexAction(Request $request)
{
return new Response('foo');
}
public function testingAction(Request $request)
{
return new Response('Bar');
}
}
When I run it I get the following error: LogicException in ControllerResolver.php line 69: Unable to parse the controller name "Default".
My folder structure is a bit different than symfony's default. My Bundle is inside /root/app/mdBundle/
(<-- From here it is the same as Symfony). Anybody has any idea why this is not working.
Or what could be another way to accomplish this without having to annotate every single action in my 98 contollers?