Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

Unexpected ? in Laravel

So, I'm on vacation and wanted to work a little bit on a project I'm trying to wrap up.

I bring my project on a separate drive, install it in my WAMP directory and go to run "php aristan migrate" and this is what I get:

brucegust@BRUCEGUST7EFC MINGW64 /c/wamp64/www/new_nomas (bruce)
$ php artisan migrate

Parse error: syntax error, unexpected '?' in C:\wamp64\www\new_nomas\vendor\lara
vel\framework\src\Illuminate\Foundation\helpers.php on line 500

brucegust@BRUCEGUST7EFC MINGW64 /c/wamp64/www/new_nomas (bruce)
$ php -v
PHP 5.6.40 (cli) (built: Jan  9 2019 15:10:36)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

brucegust@BRUCEGUST7EFC MINGW64 /c/wamp64/www/new_nomas (bruce)
$ php artisan laravel

Parse error: syntax error, unexpected '?' in C:\wamp64\www\new_nomas\vendor\laravel\framework
\src\Illuminate\Foundation\helpers.php on line 500

Open in new window


I'm running PHP 7 on my box. The Laravel project I'm working on is also coming from a PHP 7 dynamic, so I don't know where the PHP 5.6.4 is coming from, but from what I've been able to determine, the error that I'm getting is because of PHP mismatch.

How do I fix it?
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Hey Bruce,

When you run a WAMP stack, you have 2 versions of PHP - the version your website runs and the version the command line runs (CLI). When you run php -v, it will give you the version of PHP that is referenced in your PATH environment. It is possible that you have more than one version of PHP on your system, and the PATH is pointing to an older version.

Have a look in your WAMP directory, under a folder called bin. You'll probably see several versions of PHP in there, including your 5.6.4 plus your v 7.x.x. From a command prompt, type 'path' and press enter. You'll probably see that you have the old 5.6.4 path referenced in there.

You have a few choices. You can either change the path to point to the correct version (head to your Control Panel | System | Advanced System Settings | Environment Variables) , or you can fully qualify the php exe when you run your artisan commands:

c:\wamp\bin\php\php7.3.3\php.exe artisan migrate

Open in new window

If you're using WAMP server, you may also be able to change the CLI version directly (depending on your version of WAMPServer). Right-click on the WAMP icon in your task bar, select Tools, and you'll see a menu item that says "Change PHP CLI Version" - just select the v7 version).

FYI - the error you're getting is because in the helpers.php file, they're using the null coalescing operation ( a double ?? ) which only works in v7
Avatar of Bruce Gust

ASKER

Hey, Chris!

I changed my PATH so I'm running PHP 7

User generated image
This is my laptop. I'm on vacation and I was just hoping to get a little more work done. By the time I get this figured out, I'll be back home. But it's still healthy to understand what's going on.

What else could be causing this error?
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, Chris!

I'm going to keep your comments on record in case I run into this again!