Magento2 Installation error - Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' [closed]

magento.stackexchange https://magento.stackexchange.com//questions/45720

  •  12-12-2019
  •  | 
  •  

Question

I have been trying to install the Magento 2 framework ahead of the upcoming webinar but I have been getting errors.

Has anyone been able to install via CLI or the web UI?

Here is the error:

Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/magento2/dev/shell/run_data_fixtures.php on line 25'

And here is line 25

use Magento\Framework\App\State as AppState;

I've downloaded directly from the GitHub repo and haven't made any code changes yet!

Was it helpful?

Solution

It seams that you have 2 different php versions.
5.4.17 for "browser mode" and 5.2.17 for command line.
While running the install process the file dev/shell/run_data_fixtures.php is called via command line. Look at the method Magento\Setup\Model\Installer::installDataFixtures.
PHP 5.2 cannot use namespaces.
Namespaces are available starting 5.3.
SO you need to upgrade your CLI version of php to 5.4. This is the minimum supported version for magento 2.

OTHER TIPS

I had to run the following from the CLI inside the setup folder:

  1. cd setup
  2. Run the following:

php55 -f index.php install --cleanup_database --db_host=localhost --db_name=magento_2 --db_user="username" --db_pass="password" --backend_frontname=admin --base_url=http://domainname/ --language=en_US --timezone=Europe/London --currency=GBP --admin_lastname=LastName --admin_firstname=FirstName --admin_email=email@email.co.uk --admin_username=admin --admin_password=admin_password --use_secure=0

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top