skip to Main Content

I’m having to move my laravel 5.4 app to a >=PHP 7.3 Server. Upgrading the App to a higher laravel version breaks everything. So I’m stuck with making this work as is. The problem now is that Compact() method (which was used to pass variables to the view is undefined). I’m considering writing a replica of the Compact method in a helper class to make it globally available. Now I can’t even replicate the PHP compact method natively. Please help with any suggestions. Whether on how to fix the issue or with a sample alternative code to the compact method.

2

Answers


  1. you are using an older version of laravel with new version of php.

    either you can change your php version to downgrade or you can move to Laravel 5.5

    check detail here

    Login or Signup to reply.
  2. You should use compact():

    $name = 'James';
    surname = 'Hetfield'
    return view('some-template-name', compact('name', 'surname'));
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search