Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected character in input: '\' while installing Laravel 4 in a dreamhost account

I've been trying for the last hours to install Laravel 4 on my dreamhost account but I keep getting this error:

Warning: Unexpected character in input:  '\' (ASCII=92) state=1 in /home/user/test/artisan on line 46

Parse error: syntax error, unexpected T_STRING in /home/user/test/artisan on line 46

When I run

/usr/local/bin/php-5.4 -d memory_limit=256M composer.phar create-project laravel/laravel test

I've read that it may be because I use the wrong php version, but I've run the command above with

  • /usr/local/bin/php-5.4
  • /usr/local/bin/php-5.3
  • /usr/local/php53/bin/php
  • /usr/local/php54/bin/php

With the same result. Any ideas? Thanks in advance!

like image 896
juanlu Avatar asked Feb 16 '23 03:02

juanlu


1 Answers

As mentioned by the answer from Sheikh Heera, the composer.phar must be run with PHP 5.3 or higher.

What has not been mentioned yet is that composer.json contains several references to PHP binary. When installing Laravel in an environment where PHP defaults to a version lower than 5.3 (e.g. WebFaction servers), all references to "php" within file composer.json must be changed to point to a newer version of PHP.

For example:

"post-install-cmd": [
  "php artisan optimize"
],

... must be changed to (something like):

"post-install-cmd": [
  "php54 artisan optimize"
],
like image 96
Simo A. Avatar answered Feb 26 '23 20:02

Simo A.