barryvdh / laravel-ide-helper

IDE Helper for Laravel
MIT License
14.28k stars 1.17k forks source link

The Error "Class 'Doctrine\DBAL\Driver\PDOConnection' not found" in 'ide-helper:meta' #1328

Open Atantares opened 2 years ago

Atantares commented 2 years ago

Versions:

Question:

After upgrading from Laravel 8 to Laravel 9 I have an error during the command: php artisan ide-helper:meta Stack: PHP Warning: Uncaught ReflectionException: Class 'Doctrine\DBAL\Driver\PDOConnection' not found. in /var/www/html/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php:152 Stack trace:

0 [internal function]: Barryvdh\LaravelIdeHelper\Console\MetaCommand->Barryvdh\LaravelIdeHelper\Console{closure}()

1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(66): class_exists()

2 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection()

3 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection()

4 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(184): Illuminate\Database\Connectors\MySqlConnector->connect()

5 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors{closure}()

6 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(1064): call_user_func()

7 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(1100): Illuminate\Database\Connection->getPdo()

8 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(442): Illuminate\Database\Connection->getReadPdo()

9 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(368): Illuminate\Database\Connection->getPdoForSelect()

10 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(709): Illuminate\Database\Connection->Illuminate\Database{closure}()

11 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(676): Illuminate\Database\Connection->runQueryCallback()

12 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(376): Illuminate\Database\Connection->run()

13 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2536): Illuminate\Database\Connection->select()

14 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2524): Illuminate\Database\Query\Builder->runSelect()

15 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3058): Illuminate\Database\Query\Builder->Illuminate\Database\Query{closure}()

16 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2525): Illuminate\Database\Query\Builder->onceWithColumns()

17 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(655): Illuminate\Database\Query\Builder->get()

18 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(639): Illuminate\Database\Eloquent\Builder->getModels()

19 /var/www/html/vendor/spatie/laravel-settings/src/SettingsRepositories/DatabaseSettingsRepository.php(28): Illuminate\Database\Eloquent\Builder->get()

20 /var/www/html/vendor/spatie/laravel-settings/src/SettingsMapper.php(82): Spatie\LaravelSettings\SettingsRepositories\DatabaseSettingsRepository->getPropertiesInGroup()

21 /var/www/html/vendor/spatie/laravel-settings/src/SettingsMapper.php(37): Spatie\LaravelSettings\SettingsMapper->fetchProperties()

22 /var/www/html/vendor/spatie/laravel-settings/src/Settings.php(233): Spatie\LaravelSettings\SettingsMapper->load()

23 /var/www/html/vendor/spatie/laravel-settings/src/Settings.php(102): Spatie\LaravelSettings\Settings->loadValues()

24 /var/www/html/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php(152): Spatie\LaravelSettings\Settings->__debugInfo()

25 [internal function]: Barryvdh\LaravelIdeHelper\Console\MetaCommand->Barryvdh\LaravelIdeHelper\Console{closure}()

26 /var/www/html/vendor/fakerphp/faker/src/Faker/Factory.php(63): class_exists()

27 /var/www/html/vendor/fakerphp/faker/src/Faker/Factory.php(38): Faker\Factory::findProviderClassname()

28 /var/www/html/vendor/fakerphp/faker/src/Faker/Factory.php(23): Faker\Factory::getProviderClassname()

29 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php(93): Faker\Factory::create()

30 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(873): Illuminate\Database\DatabaseServiceProvider->Illuminate\Database{closure}()

31 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(758): Illuminate\Container\Container->build()

32 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(855): Illuminate\Container\Container->resolve()

33 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Foundation\Application->resolve()

34 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): Illuminate\Container\Container->make()

35 /var/www/html/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php(97): Illuminate\Foundation\Application->make()

36 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Barryvdh\LaravelIdeHelper\Console\MetaCommand->handle()

37 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()

38 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()

39 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()

40 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call()

41 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call()

42 /var/www/html/vendor/symfony/console/Command/Command.php(291): Illuminate\Console\Command->execute()

43 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run()

44 /var/www/html/vendor/symfony/console/Application.php(989): Illuminate\Console\Command->run()

45 /var/www/html/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand()

46 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()

47 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\Component\Console\Application->run()

48 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run()

49 /var/www/html/artisan(37): Illuminate\Foundation\Console\Kernel->handle()

50 {main}

Next Illuminate\Database\QueryException: Class 'Doctrine\DBAL\Driver\PDOConnection' not found. (SQL: select name, payload from settings where group = general) in /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:716 Stack trace:

0 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(676): Illuminate\Database\Connection->runQueryCallback()

1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(376): Illuminate\Database\Connection->run()

2 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2536): Illuminate\Database\Connection->select()

3 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2524): Illuminate\Database\Query\Builder->runSelect()

4 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3058): Illuminate\Database\Query\Builder->Illuminate\Database\Query{closure}()

5 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2525): Illuminate\Database\Query\Builder->onceWithColumns()

6 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(655): Illuminate\Database\Query\Builder->get()

7 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(639): Illuminate\Database\Eloquent\Builder->getModels()

8 /var/www/html/vendor/spatie/laravel-settings/src/SettingsRepositories/DatabaseSettingsRepository.php(28): Illuminate\Database\Eloquent\Builder->get()

9 /var/www/html/vendor/spatie/laravel-settings/src/SettingsMapper.php(82): Spatie\LaravelSettings\SettingsRepositories\DatabaseSettingsRepository->getPropertiesInGroup()

10 /var/www/html/vendor/spatie/laravel-settings/src/SettingsMapper.php(37): Spatie\LaravelSettings\SettingsMapper->fetchProperties()

11 /var/www/html/vendor/spatie/laravel-settings/src/Settings.php(233): Spatie\LaravelSettings\SettingsMapper->load()

12 /var/www/html/vendor/spatie/laravel-settings/src/Settings.php(102): Spatie\LaravelSettings\Settings->loadValues()

13 /var/www/html/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php(152): Spatie\LaravelSettings\Settings->__debugInfo()

14 [internal function]: Barryvdh\LaravelIdeHelper\Console\MetaCommand->Barryvdh\LaravelIdeHelper\Console{closure}()

15 /var/www/html/vendor/fakerphp/faker/src/Faker/Factory.php(63): class_exists()

16 /var/www/html/vendor/fakerphp/faker/src/Faker/Factory.php(38): Faker\Factory::findProviderClassname()

17 /var/www/html/vendor/fakerphp/faker/src/Faker/Factory.php(23): Faker\Factory::getProviderClassname()

18 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php(93): Faker\Factory::create()

19 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(873): Illuminate\Database\DatabaseServiceProvider->Illuminate\Database{closure}()

20 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(758): Illuminate\Container\Container->build()

21 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(855): Illuminate\Container\Container->resolve()

22 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Foundation\Application->resolve()

23 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): Illuminate\Container\Container->make()

24 /var/www/html/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php(97): Illuminate\Foundation\Application->make()

25 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Barryvdh\LaravelIdeHelper\Console\MetaCommand->handle()

26 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()

27 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()

28 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()

29 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call()

30 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call()

31 /var/www/html/vendor/symfony/console/Command/Command.php(291): Illuminate\Console\Command->execute()

32 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run()

33 /var/www/html/vendor/symfony/console/Application.php(989): Illuminate\Console\Command->run()

34 /var/www/html/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand()

35 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()

36 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\Component\Console\Application->run()

37 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run()

38 /var/www/html/artisan(37): Illuminate\Foundation\Console\Kernel->handle()

39 {main}

thrown in /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 716

Symfony\Component\ErrorHandler\Error\FatalError

__debuginfo() must return an array

at vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php:152 148▕ */ 149▕ protected function registerClassAutoloadExceptions(): callable 150▕ { 151▕ $autoloader = function ($class) { ➜ 152▕ throw new \ReflectionException("Class '$class' not found."); 153▕ }; 154▕ spl_autoload_register($autoloader); 155▕ return $autoloader; 156▕ }

  +28 vendor frames 

29 artisan:37

Does anyone have the same issue/bug? I made the upgrade by the official Laravel guide... The connection is okay, and the database works well in the application

nztim commented 2 years ago

I'm experiencing a similar error with the meta command after upgrading to Laravel 9 but it's complaining about a different class: Class 'Symfony\Component\Translation\TranslatorInterface' not found.

I found that allowing package auto-discovery made the problem go away, don't know why that might be but it might lead to the cause of the problem. Do you have it disabled as well?

alpfilho commented 2 years ago

i'm experiencing the same issue, but with Class 'Symfony\Component\Translation\TranslatorInterface' not found in Laravel 9 and Php 8.1

nztim commented 2 years ago

Steps to reproduce my problem (PHP 8.1):

  1. composer create-project laravel/laravel laravel
  2. Edit composer.json: "dont-discover": ["*"]
  3. composer require --dev barryvdh/laravel-ide-helper
  4. Add conditional registration to AppServiceProvider.php copied from docs
  5. Add generate and meta commands to composer.json post-update-cmd section as per docs
  6. Run composer update: meta command produces the error Uncaught ReflectionException: Class 'Symfony\Component\Translation\TranslatorInterface

If you do all the above but allow package discovery then there is no error and the meta file is created normally.

I'm assuming this is the same issue as the OP, if it's not then I can create a new topic.

nikserg commented 2 years ago

Same issue, During class fetch: Uncaught ReflectionException: Class 'Symfony\Component\Translation\TranslatorInterface' not found. in /var/www/html/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php:152

PHP 8.1

brysem commented 2 years ago

I'm experiencing a similar error with the meta command after upgrading to Laravel 9 but it's complaining about a different class: Class 'Symfony\Component\Translation\TranslatorInterface' not found.

I found that allowing package auto-discovery made the problem go away, don't know why that might be but it might lead to the cause of the problem. Do you have it disabled as well?

I found this issue too after upgrading to Laravel 9. After some searching I found a solution in a comment to the issue in the Carbon repository. https://github.com/briannesbitt/Carbon/issues/2536#issuecomment-1022555663

I added the following to my bootstrap/app.php file. The problem is now solved image

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.