Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

On my Local server everything was good was using mailtrap mail server as smtp server. but when my website is on live server and when I trying to reset password (forgot password ) getting following error screenshot is attached.I am using hostgators cpanels inbuilt smtp. any more details I will provide if needed.enter image description here

like image 262
Rakesh K Avatar asked Feb 14 '18 12:02

Rakesh K


2 Answers

You need to install PHP version 7.1 because nullable types were introduced in 7.1:

?string $value

And from the Laravel docs:

You will need to make sure your server meets the following requirements:

PHP >= 7.1.3

like image 195
Alexey Mezenin Avatar answered Nov 09 '22 10:11

Alexey Mezenin


For php7.0 only

If your server doesn't have php 7.1 and above and you are only restricted to use php7.0 do as below:

  1. Delete vendor folder
  2. Delete composer.lock file
  3. Add this to composer.json file under config

    "platform": {
       "php": "7.0.0"
    }
    

As well, ensure PHP version under require is set to 7.0.0 as shown below in config.platform.php:

    "config": {
        "platform": {
            "php": "7.0.0"
        }
     }
  1. Run composer install using CMD

This now will make sure that only dependencies compatible with php7.0 are installed.

like image 6
mutiemule Avatar answered Nov 09 '22 12:11

mutiemule