New Laravel Install V 5.4 Index.php Throwing Parsing Error. PHP 7.2.10-0ubuntu0.18.04.1

- 1 answer

New Laravel install on Digital Ocean, Ubuntu. Current PhP install. Apache2 is accessing Php just fine as I added a couple lines of code to spit out errors. This is the output:

Parse error: syntax error, unexpected '=' in /var/www/html/blog/vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 388

    public static function pluck($array, $value, $key = null)
    $results = [];
    [$value, $key] = static::explodePluckParameters($value, $key);
    foreach ($array as $item) {
        $itemValue = data_get($item, $value);
        // If the key is "null", we will just append the value to the array and keep
        // looping. Otherwise we will key the array using the value of the key we
        // received from the developer. Then we'll return the final array form.
        if (is_null($key)) {
            $results[] = $itemValue;
        } else {
            $itemKey = data_get($item, $key);
            if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
                $itemKey = (string) $itemKey;
            $results[$itemKey] = $itemValue;
    return $results;

Line 888 is:

[$value, $key] = static::explodePluckParameters($value, $key);

Laravel automatically creates a key when creating a new site with "laravel new (site name)"

Server is running my other sites just fine. I've done several clean Laravel installs, same problem.



This is happening because the PHP that is evaluating this script is not version 7.2. It's a version lower than 7.1. Array destructuring assignment was introduced in 7.1 -

You need to figure out which PHP versions are installed and exactly which one is executing the code.