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

daverona's avatar

Does Laravel 5.5 use PHP 7.1?

Hi, I wonder if Laravel 5.5 uses PHP 7.1 (although Documentation says PHP 7.0). I got the following error:

Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)

originated from

vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php

This Symfony file uses type-hinting with ? operator.

Please confirm if you can (then I can rest, I guess).

Thanks.

P.S. You can reproduce this error with the following steps:

  1. Install Laravel using composer
  2. Do "php artisan make:auth"
  3. Make a user account
  4. Do a password reset
0 likes
6 replies
tykus's avatar

This Symfony file uses type-hinting with ? operator.

It does?

I have seen that (or similar) error when attempting to run a L5.5 app on a webserver running PHP5.6; if I recall it was the use of a null coalescing operator.

Are you sure that your web server (not same as CLI) is running with PHP7?

1 like
martinbean's avatar

@egkim I believe it’ll be “nullable” type-hints Symfony’s using in method signatures, i.e.

public function someMethod(?string $var)
{
    //
}

That css-selector package seems to require PHP 7.1, so I think Composer will install it if you have PHP 7.1 installed, or fall back to a suitable version if you’re still running 7.0.

3 likes
jcmargentina's avatar

I am using laravel 5.5 in production with Ubuntu with php 7.1 ,. with no probems at all.

What are you using for development?

Can you please execute the command "php -version" and show us the output? just to double check everything is setup correctly.

Caine's avatar

I had the same issue, it helps if you install/enable PHP 7.1


#This installs php7.1
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.1 php7.1-xml php7.1-mysql php7.1-curl php7.1-mbstring

#This enables Apache to run php7.1
sudo a2dismod php7.0
sudo a2enmod php7.1
sudo service apache2 restart

jcmargentina's avatar

you are probably running you server instance with PHP5.X

please execute "php -version" and ALSO please .... try to get a file trhough your server with just only the "phpinfo()" function to see actually wich php version is running in your web server

rayyue300's avatar

I have the same issues.

Running Laravel 5.5 under PHP 7.0.

When a user fills in the email and click the reset button, following error is shown.

/vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php
public function translateExists(XPathExpr $xpath, string $attribute, ?string $value)

It seems that the nullable type should not be in PHP7.0.

I checked my composer.lock for "css-selector" and found the following:

"name": "symfony/css-selector",
"version": "v4.0.3",
"require": { "php": "^7.1.3" },

Is it the reason? v4.0.3 has been used since I installed Laravel.

( My Homestead environment is using PHP 7.2. Password reset works fine. )

1 like

Please or to participate in this conversation.