Symfony/Console cache:clear – Cannot declare a class already in use

Before starting, i want to apologize for my mistakes, i’m french and not very strong to speak english. Thank you!

So, today 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 AppControllerAdminCrudUserCrudController, 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 AppControllerAdminCrudUserCrudController, because the name is already in use ["exception" => SymfonyComponentErrorHandlerErrorFatalError { …}]

In UserCrudController.php line 15:
                                                                                                                        
  Compile Error: Cannot declare class AppControllerAdminCrudUserCrudController, 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 AppControllerAdminCrud;

use AppEntityUser;
use ...

class UserCrudController extends AbstractCrudController
{

Thanks for your help !

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *