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

vd's avatar
Level 2

Is PHP 7.1 required for Laravel 5.5?

Hi,

Today I received an error when tried to reset a password using Laravel native controllers...

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

This error is related to the AttributeMatchingExtension class in vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php file. In that file I found following syntax:

public function translateExists(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
    {
        return $xpath->addCondition($attribute);
    }

I am working with Laravel 5.5 and PHP 7.0.29, which is good according to the default composer.json, but feature with nullable type declaration like ?string $value appears only in PHP 7.1.

Is it some way to keep Laravel 5.5 running on PHP 7.0.*?

0 likes
5 replies
rin4ik's avatar

Laravel 5.5 requires PHP 7.0.0 or higher.. are you sure your php version 7 ? in console run php -v and in your routes file put this code and check

Route::get('phpinfo', function(){
   phpinfo();
});
1 like
vd's avatar
Level 2

Yes, I am sure, I receive an error with php version 7.0.29, if I change version to the 7.2.4 it works as expected...

I have even tried that with fresh Laravel installation, in vendor class ?string $value code is present

rin4ik's avatar

@vd you are welcome. I told you about php -v earlier, php version the webserver uses and command line version should always match

Please or to participate in this conversation.