1

This is a strange one, I have never come across it before - but then I've not used Symfony 3.1, only 2.8.

When I run a console command such as clear:cache or a doctrine:schema:update, I get the following error on terminal:

PHP Parse error: syntax error, unexpected '[', expecting ')' in /var/www/vhosts/mycrmsitetest.co.uk/httpdocs/bin/console on line 20

The line its referring to in the console file is:

$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');

This is exactly the same as on my local drive, but it works there - it's only when it's on the server that this fails.

Does anyone know what this may be?

Michael Emerson
  • 1,774
  • 4
  • 31
  • 71
  • 1
    Possible duplicate of [PHP Parse/Syntax Errors; and How to solve them?](http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) (tl;dr: the PHP on the server is an older version than what you have locally.) – JJJ Sep 13 '16 at 16:20
  • I guess that you have old PHP version, that doesn't support new array syntax yet. – Jakub Matczak Sep 13 '16 at 16:24

1 Answers1

2

You need PHP version greater then 5.4. Your script contains the new array syntax ('[]' instead of 'array()'): http://php.net/manual/en/migration54.new-features.php

Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97
Dmitry Malyshenko
  • 3,001
  • 1
  • 12
  • 20
  • Yes, that's the issue. But I cannot update PHP on command line, even though Plesk states it's using 5.6, when I type php -v it tells me it's using 5.3.3 (and it's not something I can really change :( ) – Michael Emerson Sep 14 '16 at 08:46