1

I have a problem with symfony 5.1 and the cache:clear command line.

All of my work is working great on the browser. I've make some refactoring and move some pictures and I had a problem (it was due to a bad way), but before know this I went to clear the cache to verify.

This is what the terminal tells me:

$ sc cache:clear

 // Clearing the cache for the dev environment with debug true                                                          

PHP Fatal error:  Cannot declare class App\Controller\Admin\Crud\UserCrudController, because the name is already in use in /home/mathieu/projets/alghazali/site/src/Controller/Admin/Crud/UserCrudController.php on line 15
10:37:38 CRITICAL  [php] Fatal Compile Error: Cannot declare class App\Controller\Admin\Crud\UserCrudController, because the name is already in use ["exception" => Symfony\Component\ErrorHandler\Error\FatalError { …}]

In UserCrudController.php line 15:
                                                                                                                        
  Compile Error: Cannot declare class App\Controller\Admin\Crud\UserCrudController, because the name is already in use  
                                                                                                                        

cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

exit status 255

I don't know what can I show you for better understanding.

You have maybe to know I'm using the EasyAdminBundle 3.

This is my tree structure:

My-project
|
└─ src/
    ├─ .../
    |
    ├─ Controller/
    |     ├─ Admin/
    |     |     ├─ Crud/
    |     |     |    ├─ PostCrudController.php
    |     |     |    └─ UserCrudController.php
    |     |     |    
    |     |     └─ AdminDashboardController.php
    |     |
    │     ├─ MainController.php
    │     ├─ PostController.php
    │     └─ SecurityController.php
    |
    ├─ Entity/
    |     ├─ ...
    |     ├─ Post.php
    |     └─ User.php
    |
    ├─ Repository/
    |     └─ ...
    |
    └─ Kernel.php

In the src/Controller/Admin/Crud/UserCrudController.php file, I have that:

<?php

namespace App\Controller\Admin\Crud;

use App\Entity\User;
use ...

class UserCrudController extends AbstractCrudController
{
9
  • have you tried removing the cache manually ? with " rm -r var/cache/* " Commented Sep 10, 2020 at 9:29
  • Thanks. Yes but no change Commented Sep 10, 2020 at 12:30
  • have you tried automatically search the word "UserCrudController" in the whole project ? Commented Sep 10, 2020 at 12:47
  • I use sublime text and when I search in all project I am not capable to understand all the responses. However I have tried to rename my class and the file, and it's working Commented Sep 10, 2020 at 13:27
  • The class and the file have a new name, ok? I remove all is in /var/cache. I clear the cache then I look in /var/cache/dev/annotations.map and I find <?php return array ( 0 => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController', 1 => 'App\\Controller\\Admin\\AdminDashboardController', 2 => 'App\\Controller\\Admin\\Crud\\PostCrudController', 3 => 'App\\Controller\\Admin\\EditorDashboadController', 4 => 'App\\Controller\\Crud\\Admin\\UserCrudController', ...etc but EditorDashboadController and UserCrudController have been normally removed Commented Sep 10, 2020 at 13:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.