Laravel:syntax error in vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 384

Viewed 13918

I tried to make a new laravel project work on my debian vps but nothing go right. I init the project with the basic composer create-project laravel/laravel, change the permissions to 755 so everything that is explained here.

But I always have an error 500 when I tried to access to my <pathToMyProject>/public folder and when I read my php's logs is see this message :

PHP Parse error: syntax error, unexpected '=' in /vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 384

What can be the problem ? I precise that my php version is >7.1

5 Answers

It is possible that the CLI version of PHP is 7.2 but apache is using an older version of PHP. Would be worth adding a phpinfo.php in the root of your public folder containing

<?php 

phpinfo();

the navigate to your http://www.yoursite.com/phpinfo.php and double check the version.

Ensure you remove the phpinfo.php file once you have tested.

I faced the same problems. I resolved it by running the following commands.

php -v

It displays the current running php version => 7.0

a2dismod php7.0

It will be disabled php7.0 version.

a2enmod php7.2

It will be enabled php7.2 version.

service apache2 restart

Just Ensure you upgrade your php version on the server like from 7.0 to something like 7.3. if you are using the CPanel navigate to Web Tools then PHP Configuration and change the php version

I encountered this error using laravel in cpanel.

  1. Go to composer.json
  2. Check PHP version
  3. Go to the Cpanel dashboard
  4. Software > Select PHP version
  5. change PHP version to $php_version
  6. save and retry

My problem was that I have only installed php 7.0.

If it is your problem too. Do bellow step for installing 7.2:

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt-get install php7.2
Related