Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel unable to modify queued job code

When I send a job that fails due to an exception such as 'ErrorException' with message 'Undefined variable: sender' and I fix the code and re-fire the event, the previous code runs again and I get the same error.

I have no idea why Laravel re-runs my old code over and over. I'd obviously like to be able to fix the mistakes that are breaking my job execution.

I've tried both composer dump-autoload and php artisan queue:flush and those have no effect. Any help?

like image 715
tim peterson Avatar asked Sep 29 '15 03:09

tim peterson


2 Answers

My Laravel 5.1 config/compile.php file is empty but this helped me:

sudo service beanstalkd restart

and

php artisan queue:restart

Laravel often lacks of good and accurate documentation.

like image 51
sba Avatar answered Sep 23 '22 00:09

sba


You need to run php artisan clear-compiled to clear compiled files.

If you look at config/compile.php you will see some extra providers (or other classes) are cached by default by Laravel.

If you made any changes for example in EventServiceProvider and it was earlier cached, Laravel won't see those changes in case php artisan optimize command was earlier launched (and looking at https://github.com/laravel/laravel/blob/master/composer.json you will see it is launched after running composer install or composer update).

This feature has nothing in common with composer itself but with Laravel that's why running composer dump-autoload won't help.

like image 24
Marcin Nabiałek Avatar answered Sep 20 '22 00:09

Marcin Nabiałek