0

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.

1
  • The error seems pretty clear to me, somewhere the $operator variable is not defined, but it's used in compact(). Locate all the $operator variables and you will be able to see where it's not defined. Also, preview the complete log of the above error in storage/logs. Commented Nov 18, 2019 at 13:25

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

If:

  1. You can't upgrade for whatever business/team related reason and
  2. Are sure that the Homestead box is running the correct version of PHP (7.2 or lower based on the answer given here) and yet
  3. are still getting this error,

explicitly define the PHP version on the Homestead.yaml file. This should be done on the sites property as such (each is a new line, of course):

map: test.appp /home/vagrant/code/test/public php: "7.1"

Comments

0
if ($form->scholarship_type == 'doctor2') {
    $Degree = "doctor";
    return view('scholarship/UI_scholarship.Under_higher_education.index', compact(['degree'=>$Degree, 'form'=>$form]));
}
if($form->scholarship_type == 'master2'){
    $Degree = "master";
    return view('scholarship/UI_scholarship.Under_higher_education.index',compact(['degree'=>$Degree, 'form'=>$form]));
}

compact(): Undefined variable $doctor

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.