doufeng1249 2017-07-25 15:39
浏览 115


Just recently we decided to upgrade from symfony 2.8 too 3.3 with this being noted I felt it was best to start a fresh symfony project and just pull over some parts of the project and change the key needed items that changed over this major version upgrade. I have worked out most of the issues however currently I get this meaning that I may have more issues that I suspect. here is the current one:

C:\xampp\htdocs\Fresh_Api>php bin/console server:run PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to lo ad class "CommandListener" from namespace "Directive\MultiTenant\MasterBundle\EventListener". Did you forget a "use" statement for another namespace? in C:\xampp\htdocs\Fresh_Api\var\cache\dev\a ppDevDebugProjectContainer.php:580 Stack trace:
#0 C:\xampp\htdocs\Fresh_Api\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Contai ner.php(331): appDevDebugProjectContainer->getAppBundle_CommandListenerService()
#1 C:\xampp\htdocs\Fresh_Api\var\cache\dev\appDevDebugProjectContainer.php(965): Symfony\Component\D ependencyInjection\Container->get('app_bundle.comm...')
#2 C:\xampp\htdocs\Fresh_Api\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php(229): appDevDebugProjectContainer->{closure}()
#3 C:\xampp\htdocs\Fresh_Api\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\EventDispatcher.php(61):Symfony\Component\EventDispatcher\EventDispatcher->sortListeners('console.command')
#4 C:\x in C:\xampp\htdocs\Fresh_Api\var\cache\dev\appDevDebugProjectContainer.php on line 580

This is of course after I try running php bin/console server:run

I have tried deleting my cache, deleting my autoload file, deleting my vendor file and reinstalling composer. I have tried to look to see if there are any dependencies that are missing. (I could have missed something here)

The file it's talking about is a generated file so something about it is not properly noticing that that class exists.

Here is the CommandListener

namespace Directive\MultiTenant\MasterBundle\EventListener;

use Directive\MultiTenant\MasterBundle\Connection\ConnectionWrapper;
use Directive\MultiTenant\MasterBundle\Entity\Tenant;
use Directive\MultiTenant\MasterBundle\Repository\TenantRepository;
use AppBundle\TenantProviderInterface;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Exception;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Input\InputOption;

The appDevDebugProjectContainer is a little large so I'll wait to see if there are any response to see if it's even needed as I'm sure it's something else that is causing it not to generate the proper information needed.

thanks for any input you have.

EDIT: This is a link here noting it's the same issue however this exact issue there is already resolved before all this. Here is my code for that section.

 "autoload" : {
    "psr-4": {
        "AppBundle\\": "src/AppBundle"
    "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]

This was already fixed already. here is another link I used to try to solve my issue that of course had no help.

php bin/console symfony commands give a fatal error

and another

Symfony 3.3 Getting ClassNotFoundException

  • 写回答

1条回答 默认 最新

  • dongtang6775 2017-07-25 17:10

    All Credit goes to Cerad the answer is sadly duplicated however I did not notice something that was needed. the autoloader needs to know where it is pulling classes from and has to be setup with the new way the symfony does it now. Here is my example with my additional code to make it work.

    "autoload" : {
        "psr-4": {
            "AppBundle\\": "src/AppBundle",
            "BundleName\\": "src/BundleName"
        "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 Arduino,利用modbus的RS485协议,进行对外置的温湿度传感器进行数据读取
  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么