-1

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

5
  • Edited adding other things I've tried already including the one used as a "duplicate" does anyone have a better idea? Commented Jul 25, 2017 at 16:00
  • Your posted autoload "fix" is wrong. Commented Jul 25, 2017 at 16:18
  • The autoload idea was not a fix for my issue as stated it was an attempt to fix the issue only noting it for that reason. Commented Jul 25, 2017 at 16:23
  • No idea what that means. I do know that thanks to a fairly recent change to the default composer.json file, classes with a prefix other than AppBundle will no longer autoload resulting in class not found exceptions. Which is exactly what you seem to be getting. But if you feel that is not the problem then fine. Commented Jul 25, 2017 at 16:28
  • Cerad I did not realize the connection of how this worked now. Thank you for your input and sorry for not taking more time to ask about what you were trying to point out. I hope this helps someone that doesn't see it just like myself. Commented Jul 25, 2017 at 17:02

1 Answer 1

0

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" ]
},
Sign up to request clarification or add additional context in comments.

Comments

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.