0

I've recently got a new PC and started to migrate the development of my project over to it. I've installed php, composer and git and checked it out. I run composer install, which pulls in all of the dependencies but then throws the following error:

Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
PHP Fatal error:  Uncaught RuntimeException: A facade root has not been set. in /home/user/PhpstormProjects/project/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:234
Stack trace:
#0 /home/user/PhpstormProjects/project/app/Exceptions/Handler.php(61): Illuminate\Support\Facades\Facade::__callStatic('environment', Array)
#1 /home/user/PhpstormProjects/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(353): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /home/user/PhpstormProjects/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(132): Illuminate\Foundation\Console\Kernel->reportException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#3 /home/user/PhpstormProjects/project/artisan(33): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
# in /home/user/PhpstormProjects/project/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 234

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

I've tried to delete the vendor directory and the composer.lock file and then re-run composer install, but I get the same error. It runs fine on my old machine. Am I missing a step here?

Alex
  • 3,031
  • 6
  • 34
  • 56
  • Have you tried one of the solutions that already exist for the same error? Such as this one [here](https://stackoverflow.com/a/43850011/1457270)? – nakov May 08 '19 at 19:12
  • That (and the answers that I've been looking at) relate to changes to the code. I'm convinced that this is an infrastructure problem because it runs absolutely fine when running the same process on a different machine. – Alex May 08 '19 at 19:16
  • Is Laravel the same version as the one you have on the old machine? – Carlos Alves Jorge May 08 '19 at 19:17
  • Yes, Laravel is pulled in when I run `composer install`. The `composer.json` files are identical (they're from the same git repository). – Alex May 08 '19 at 19:19
  • And you have also run composer install on the old machine today right? So... exactly the same... Can you try php artisan config:cache php artisan config:clear php artisan cache:clear composer update – Carlos Alves Jorge May 08 '19 at 19:23
  • Correct. I've just checked out a fresh copy and followed my workflow to the letter on the old machine and it works fine. Running any `php artisan` command results in the above error. If you look at the last line, it's actually `php artisan package:discover` that's causing the error. – Alex May 08 '19 at 19:26
  • Could something to do with php version i.e. if laravel versions in old and new are the same, guess now the problem is php – Johhn May 08 '19 at 19:39
  • Potentially. I'm having a look through the logs now and I'm getting a `[2019-05-08 20:41:06] laravel.ERROR: Undefined class constant 'MYSQL_ATTR_LOCAL_INFILE' {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Undefined class constant 'MYSQL_ATTR_LOCAL_INFILE' at /home/user/PhpstormProjects/project/config/database.php:60) [stacktrace]` error. The `database.php` config file is calling `\PDO::MYSQL_ATTR_LOCAL_INFILE => true` on the line in question. I'm assuming it could be something to do with that. – Alex May 08 '19 at 19:43
  • Good update -- I was going to comment that it looks like the Facade Root error is happening by using the `App` facade in your error handler. Definitely looks like an issue with PHP and its extension(s), possibly a missing PDO driver. – Aken Roberts May 08 '19 at 19:46
  • Good shout. `php7.3-mysql` was missing. Thanks all! – Alex May 08 '19 at 19:48

1 Answers1

0

After scouring the logs, it turns out that this was down to a missing php7.3-mysql driver. Running sudo apt-get install php7.3-mysql solved the problem!

Alex
  • 3,031
  • 6
  • 34
  • 56