Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

php - Symfony 5.2 Bundle Route Annotations Not Checked

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...