Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

@tsommie's avatar

Laravel 5.5 syntax error, unexpected '?' in ..\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php on line 233

I just installed a fresh copy of Laravel 5.5 on my machine and when i run the "php artisan serve" i get a syntax error that reads "unexpected '?' in ..\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php on line 233"... Any fix for this?

0 likes
12 replies
36864's avatar

Make sure you're running PHP 7.0

8 likes
lorvent's avatar

if php7 is not running then it wont install at all as composer has that requirement.

3 likes
36864's avatar

Having PHP 7 installed is not the same as running PHP 7.

The error on that line is being thrown because a null coalescing operator is being used, which was added in PHP 7 and is incompatible with php 5.

2 likes
nonografis's avatar

I have install laravel 5 on new AppServ with composer command line. I have some error bugs as @TSOMMIE. I'm switch my php version from php5 to php7. And Now, i can run my laravel. Good luck.

muragijimana's avatar

I think the solution can be this: sudoa2dismod php5.6or remove any php down to 7.0 then sudo a2enmod php7.0 as Laravel 5.5 require strictly php7.0 which is double fast to php 5.6 thank you.

Cronix's avatar

Yes, if possible, use php 7+, even if the minimum for a particular laravel version is 5.6. PHP7 is leaps and bounds faster than 5.6 and uses less memory on top of that! The engine has been totally rewritten and It's literally almost 2x as fast as PHP 5.6.

There's some benchmarks for Laravel and Wordpress here: http://www.hongkiat.com/blog/php7/

Jenry's avatar

Yeah, I had this same issue and realise that PHP have to be running. I'm on mac. simply doing "source ~/.profile" got things running for me, as that has the php 7 path configured.

Do "php -v" on your command line, and it will tell you which version of php is running so you'll know if the version is the issue or not.

planetjoin's avatar

Hello

I read all this, but i still having the same error.

php -v ea-php-cli Copyright 2017 cPanel, Inc. PHP 7.1.17 (cli) (built: Apr 26 2018 16:12:59) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

i run a phpinfo.php file to get the PHP version.. 7.1.17

all looks perfect..

but still

Parse error: syntax error, unexpected ')' in /home/user/public_html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233

I use cloudlinux in my server.

Thanks for any help ;) Fabian

36864's avatar

@planetjoin did you edit the helpers file in any way? That's a weird one.

Please post lines 222 to 259 of that file here and also specify your laravel version.

ebonit's avatar

if you do /usr/local/bin/php -v then you most probably see that the version is not 7. That was probably the version that was installed with your linux distribution and you added php7 later on. And since that is the first php in your $PATH, that is what is used by composer

when I do which php it shows that I have created an alias for php which points to my php7:

$ which php
alias php='/usr/local/php70/bin/php'
    /usr/local/php70/bin/php

if this is the case you can do 2 things

A. you delete that /usr/local/bin/php and create a symbolic link to your php7

$ rm -f /usr/local/php
$ ln -s /usr/local/php70/bin/php /usr/local/php

or

B. in your composer.json, scroll down to the "scripts" section and where you see @php (3 times) you change that to @/usr/local/php70/bin/php. This option is not suitable if you share your work through git with other developers since their setup can be different en in that case it might cause problems for them when they do a git pull.

1 like

Please or to participate in this conversation.