-1

I just got started with laravel 5.6 got php 7.2.4 and latest version of laravel 5.6 which is according to docs requires PHP >= 7.1.3 , but the laravel fails , when I run phpunit and it thorws this error:

Parse error: syntax error, unexpected ':' 
in C:\laragon\www\forum\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php 
on line 233

and this is the line with the error:

return app('cache')->get($arguments[0], $arguments[1] ?? null);

and the problem is that php 7 does not support ?? operator so what is going on ? what version of php should I use with laravel 5.6 ? if I fix that line I have an error on another line , should I fix all this errors by myself ? please help

Mikail G.
  • 454
  • 5
  • 19
  • 1
    Make sure your php version is 7 – Mahdi Younesi Apr 05 '18 at 21:14
  • 1
    PHP 7 should support the "??" operator. It's known as the null coalesce operator, see https://lornajane.net/posts/2015/new-in-php-7-null-coalesce-operator for usage. You may need to restart apache if you recently installed PHP 7 to correct. Also check to see what binary phpunit is running. I'm betting still 5. – Tom Mulkins Apr 05 '18 at 21:16
  • 1
    What's the result of `php -v` (assuming you run `php phpunit ...`)? – Jonas Staudenmeir Apr 05 '18 at 21:24
  • Thanks I fixed the issue , turns out the global php was 5.6 – Mikail G. Apr 05 '18 at 21:48
  • someone had answered it before check the solution is [here](https://stackoverflow.com/a/45992741/9554016) – Dyaa Jun 29 '18 at 00:03

1 Answers1

0

Turns out that I installed php 7 but had php 5.6 as a global php, so php -v was returning 5.6 version , So I fixed it by going to global path and change the C:\xammp\php to new install : C:\php7

Mikail G.
  • 454
  • 5
  • 19