0

I tried to deploy laravel 5.6 using PHP deployer. The site got deployed successfully. But I see the below error while trying to access the website,

Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /mnt/data/sites/laravel_deployer/releases/5/vendor/symfony/http-foundation/Request.php on line 1587

PHP info page shows, the site is running with PHP 7.0.27 Site running with wrong PHP version

whereas the default PHP version in the deployment server is 7.1.

[surendar.m@testmachine current]$ php -v
PHP 7.1.17 (cli) (built: May 10 2018 17:38:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

I have the following doubts,

  1. Why the deployed site is not using the system default PHP version?
  2. Is this because of the PHP version mismatch I'm getting the parse error while trying to access the website?

My composer version is 1.9.1

Composer.json file is as follows,

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": "^7.1.3",
    "fideloper/proxy": "^4.0",
    "laravel/framework": "5.6.*",
    "laravel/tinker": "^1.0"
},
"require-dev": {
    "filp/whoops": "^2.0",
    "fzaninotto/faker": "^1.4",
    "mockery/mockery": "^1.0",
    "nunomaduro/collision": "^2.0",
    "phpunit/phpunit": "^7.0"
},
"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},
"extra": {
    "laravel": {
        "dont-discover": [
        ]
    }
},
"scripts": {
    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate"
    ],
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover"
    ]
},
"config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Greg
  • 5,862
  • 1
  • 25
  • 52
surendar
  • 113
  • 7
  • 1
    your composer dependencies state that you need at least 7.1.3 php. so yes it is expected to break on a server with 7.0 – Norman M Dec 11 '19 at 16:07

1 Answers1

0

The cli version of PHP and the version Apache uses don't have to match. You need to reconfigure Apache to use PHP 7.1.

instance
  • 72
  • 1
  • 6