3

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 ?

Keys_fh
  • 43
  • 5
  • Class "1\HomeController"? Where is that 1 coming from? Maybe a control code in your controller file? – Cerad Jan 31 '21 at 21:41
  • For some reason it looks like your missing a `/` in `C:\wamp64\www\crowdin\group-834932\crowdin\config/routes../../src/Controller/`, should look something like `/routes/..` – Julien B. Feb 01 '21 at 02:34
  • can you try to clear you cache ? `rm -rf var/cache/*` – Snroki Feb 01 '21 at 09:13

1 Answers1

3

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).

Martin
  • 1,066
  • 3
  • 20
  • 36