简体   繁体   中英

Symfony console component, class not found

I'm using the console component without Symfony standard edition and I'm working on my application.php file. When I run it it says:

Fatal error: Class 'GenerateTableCommand' not found in D:\\ConnectCommand\\vendor\\application.php on line 10

My code:

    <?php

require __DIR__.'\autoload.php';

use Symfony\Component\Console\Application;

    $application = new Application();

    $application->add(new GenerateTableCommand());

    $application->run();

?>

My repository can be found here if needed: https://github.com/guuse/ConnectCommand

Any help is greatly appreciated.

First of all there's no \\GenerateTableCommand , as stated in the error message.

This class is under AppBundle\\Command namespace, so it's full name is AppBundle\\Command\\GenerateTableCommand .

You should add use statement at the beggining:

use AppBundle\Command\GenerateTableCommand;

Anyway, you'll probably encounter further issues with loading this class, since you do not really have any autoloaders for your custom code, so PHP won't be able to load this class.

Also mixing 3rd party code with your own (in vendor directory) is not a good idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM