Symfony类区分大小写错误

I'm new to symfony - just got an app up and running this weekend and playing around trying to get a sense of how to put stuff together.

I created a route with a controller and a template.

routes.yaml

test:
    path: /test
    controller: App\Controller\test::initialize

test.php (controller)

namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class test extends Controller {

    public function initialize() {

        return new Response("hello test");
    }
} 

Now I would simply like to rename my class such that it adheres to the convention of class names (capitalized).

class test {...} ----> class Test {...}

And the route would follow:

test:
    path: /test
    controller: App\Controller\Test::initialize  # test becomes Test

Simple.

But when I do this I get a runtime error:

Case mismatch between loaded and declared class names: "App\Controller\test" vs "App\Controller\Test".

I tried clearing the server cache. Dont really understand from where App\Controller\test is being read after having renamed all mentions of that class.

What could be causing this error?

For anyone having this issues, the above two comment solved my problem.

  • Symfony requires that the controller filename match the class
  • run rm -r var/cache to clear cache beyond that of the bin/console cache:clear commmand