I created a bundle that has a controller with route annotations, but Symfony isn't checking those routes. I confirmed the bundle is working (it has other code that is working). I also added a var_dump
to the controller and confirmed it is being parsed.
Controller:
<?php
namespace AppmyBundleController;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentRoutingAnnotationRoute;
class myController extends AbstractController {
/**
* @return SymfonyComponentHttpFoundationResponse
*/
#[Route('/', priority: 0)]
function index(): Response
{
$response = new Response('', 200, ['content-type' => 'text/html']);
return $this->render('index.twig', ['doc' => ['title' => 'test']], $response);
}
}
services.yaml:
my_controller:
resource: "@myBundle/Controller"
public: true
type: annotation
If I put the controller in the top-level application, it works fine and Symfony checks the route.
Is there something else that needs to be done to get it to work in a bundle?
question from:
https://stackoverflow.com/questions/65927397/symfony-5-2-bundle-route-annotations-not-checked 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…