Magento – Syntax error, unexpected ‘.’ in ObjectManager\Factory\AbstractFactory.php

clicronmagento2PHP

I am trying to install Magento, but it showing me error:

syntax error, unexpected '.' in
E:\wamp\www\Magento\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php
on line 93

as per the suggestion's I had upgrade my php version. The problem is solve for temporary. After completion of installation the message show as:

System messages

One or more indexers are invalid. Make sure your Magento cron job is
running.

On searching on this topic I got suggestion to run following command:

php bin/magento indexer:reindex

but on running of this command it shows me error again:

syntax error, unexpected '.' in
E:\wamp\www\Magento\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php
on line 93

Best Answer

Note: wrong version of the php is a main issue

Try to run this command in command line:

php -v

It is possible that your cli php is different from the server's php (cli php version is older than php version used by your server). If this is so, try to change path to the php used in cli.

Your problem occurs in a line of arguments of this method:

protected function createObject($type, $args)
{
    return new $type(...array_values($args));
}

becouse your cli php can not understand (parse) the ... symbols (Argument Unpacking) that is available for the php versions >= 5.6 .

PS: Here you can find an answer for the question "How to check php version on windows command line"

Related Topic