I'm learning from scrach Symfony the version 5.0.1. I created a project with the --full option. The Annotations package is already installed.
Here is my error :
Class "1\HomeController" does not exist in C:\wamp64\www\crowdin\group-834932\crowdin\config/routes../../src/Controller/ (which is being imported from "C:\wamp64\www\crowdin\group-834932\crowdin\config/routes/annotations.yaml"). Make sure annotations are installed and enabled.
This is my HomeController (made by maker) :
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
/**
* @Route("/home", name="home")
*/
public function index(): Response
{
return new Response('<h1>Home Page</h1>');
}
}
and the annotations.yaml file :
controllers:
resource: ../../src/Controller/
type: annotation
kernel:
resource: ../../src/Kernel.php
type: annotation
Why does it not work ? I installed all the packages needed. I well followed the configuration process. Can you help me please ?
Unfortunately, you don't specify which PHP version you are using.
It looks like it could have to do with symfony/http-kernel (See src/Kernel.php).
I have managed to replicate the same issue using Symfony 5.0 and upgrading PHP from 7.3 to 8.0 then running composer update. In this scenario, I got the same error and nothing in the configuration seems to be able to fix it.
Switching PHP back to 7.3 and re-running composer update fixes it. Also using PHP 8.0, but upgrading Symfony to 5.2 fixes it (haven't tried 5.1).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With