laravel

Laravel - compact(): Undefined variable: operator in Builder.php


I have PHP version-7.3 installed in my system and Laravel-5.8. When I tried to rub composer install or composer update on an old Project with Laravel-5.4 and PHP Version-5.6.4, I got this error shown below:

In Builder.php line 1229: compact(): Undefined variable: operator Script php artisan optimize handling the post-install-cmd event returned with error code 1

Then, when I tried to run the application, I got this error page as shown on the screen:

Laravel builder

I tried to run:

php artisan cache:clear

and

composer update

but the problem is still there.

How do I get it resolved?

Thank you.


Solution

  • It looks like this issue was fixed in Laravel 5.5 according to this post: https://github.com/laravel/framework/issues/26936#issuecomment-449479336

    Since Laravel 5.4 is no longer supported, your best option might be to upgrade. You can find a list of the currently supported versions here: https://laravel.com/docs/releases

    The minimal upgrade that should still fix the error would be 5.4 to 5.5. The instructions can be found here: https://laravel.com/docs/5.5/upgrade#upgrade-5.5.0 (please note that support for 5.5 has also ended, but it might still fix your bug). This would also require you to switch the project to PHP 7.0.0 or greater.