0

When I run command php artisan schedule:run, it runs fine. However, when I put the command into the scheduler as follows:

* * * * * php /PATH/TO/PROJECT/artisan schedule:run >> /PATH/TO/PROJECT/storage/logs/scheduler.log 2>&1

I get the following error every time it runs.

PHP Fatal error:  Uncaught ReflectionException: Class log does not exist ...

This question shows that it's because of an error that happens early in the bootstrap process and tries to log an error before the logger is registered.

I can't seem to figure out where to start debugging since this is the only call stack I get:

PHP Fatal error:  Uncaught ReflectionException: Class log does not exist in /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php:734
Stack trace:
#0 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(734): ReflectionClass->__construct('log')
#1 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(629): Illuminate\Container\Container->build('log', Array)
#2 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(697): Illuminate\Container\Container->make('log', Array)
#3 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(849): Illuminate\Foundation\Application->make('log')
#4 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(804): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(773): Illuminate\Container\Container in /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 734

I suspect it may have something to do with permissions, however the crontab is tied to the same user who runs it manually. What is causing the original error?

Community
  • 1
  • 1
Jeff
  • 141
  • 1
  • 9
  • Did you try running "php artisan schedule:run" manually (without using CRON)? Do you get the same error? | Edit: also, probably related http://stackoverflow.com/a/34992628/3551175 – Skysplit Aug 26 '16 at 21:13
  • I linked to that question in my original post. The exception can be caused by different errors which trigger the framework to try and log it because the Laravel Log class is registered. – Jeff Aug 26 '16 at 21:48

1 Answers1

0

I've found what was causing my error in particular (it may/may not vary for others). After debugging through many source files I've found the source of the issue was that the PDO extension wasn't being loaded. I don't know why this was the case only when running as a cron-job.

As a note: it seems that other having the same issue often have it during the configuration phase so it might be a good idea to start debugging from there if you are getting the same exception.

Jeff
  • 141
  • 1
  • 9