statamic / cli

Install and manage your Statamic projects from the command line.
71 stars 19 forks source link

PHP Parse error in Downloader.php on line 117 #1

Closed kevnk closed 7 years ago

kevnk commented 7 years ago

After running on macOS Sierra:

$ composer global require statamic/cli

Opening a new terminal tab and checking the version:

$ statamic version

I'm getting the following error

PHP Parse error:  syntax error, unexpected '?' in /Volumes/Server/.shared/composer/vendor/statamic/cli/src/Downloader.php on line 117
kevnk commented 7 years ago

Looks like a PHP 7 feature: https://stackoverflow.com/a/34571460/622287

... now to update to php 7 ...

kevnk commented 7 years ago

Here's how to update your mac's version of php to 7.1: https://stackoverflow.com/a/2526299/622287

jasonvarga commented 7 years ago

We can look at fixing that, but yeah upgrading to PHP7 is probably a good idea anyway.

kevnk commented 7 years ago

Now to get statamic to use the php version you just installed above:

Change the first line in /path/to/composer/vendor/statamic/cli/statamic to #!/usr/bin/env /path/to/new/php. So my first line looks like this:

#!/usr/bin/env /usr/local/php5/bin/php
jasonvarga commented 7 years ago

Don't modify the files like that. You should just configure your system to use the new PHP version by default.

kevnk commented 7 years ago

Thanks @jasonvarga.

Instead, if you install PHP7 as detailed above, then you can add this to your .bash_profile:

export PATH=/usr/local/php5/bin:$PATH
alias php=/usr/local/php5/bin/php # may or may not be required. I needed it for it to work.