3

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.

0

2 Answers 2

5

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 - https://wiki.php.net/rfc/short_list_syntax

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

1
  • 1
    Aha. Current PHP version: 7.0.30-0ubuntu0.16.04.1 Parse error: syntax error, unexpected '=' in /var/www/html/foo/vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 388 Commented Nov 26, 2018 at 20:11
0

Hope this helps someone. So what you need to do is go to /etc/apache2/mods-enabled ls-l and see what php version is loaded. "sudo a2dismod php7.0" to disable php7.0 mod and use "sudo a2enmod php7.2". Restart apache2 with "systemctl restart apache2" and you should be good.

Not the answer you're looking for? Browse other questions tagged or ask your own question.