-2

I try to start a new project symfony 5 simple. When I start the server "symfony server: start", I have this answer: Parse error: syntax error, unexpected '?' In C:\Users\Philippe\Documents\my_project_name\public\index.php on line 15. I have windws 10, PHP 7.4.3, wamp server but its off.

I show you my terminal: enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
Phil31971
  • 53
  • 1
  • 2
  • 3

2 Answers2

2

Answer is simple php5.6 does not support Null coalescing operator (??). This operator is available from PHP7+ (php.net)

Solution 1:

  • Upgrade your PHP version to ^7

Solution 2:

  • Change code

  • PHP 7+ $username = $loggedUser ?? 'nobody';

  • PHP 5.6 $username = isset($loggedUser) ? $loggedUser : 'nobody';

both is equivalent, return logged user if set, otherwise nobody.

Mmx
  • 358
  • 4
  • 18
0

It says in the output that you are running "PHP cgi v5.6.40". Run symfony local:php:list and see what is available to be able to be run. You need to install PHP 7.4 as php-fpm (if available on WAMP), or php-cgi. The Symfony Server can't use the cli version to run webpages.

symfony local:php:refresh may also help, or install other versions of PHP.

> symfony local:php:list

# You'll see all supported SAPIs (CGI, FastCGI, etc.) for each version.
# FastCGI (php-fpm) is used when possible; then CGI (which acts as a FastCGI
# server as well), and finally, the server falls back to plain CGI.

from: https://symfony.com/doc/current/setup/symfony_server.html#selecting-a-different-php-version

Alister Bulman
  • 34,482
  • 9
  • 71
  • 110