Unexpected character when entering: '\' when installing Laravel 4 in dreamhost account

In the last hours, I have been trying 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 started

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

I read that this could be because I am using the wrong php version, but I executed 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!

+4
source share
3 answers

As mentioned in a response from Sheikh Heera, composer.phar must be running with PHP 5.3 or higher.

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

For instance:

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

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

 "post-install-cmd": [ "php54 artisan optimize" ], 
+7
source

In artisan , line 46 has

 $artisan = Illuminate\Console\Application::start($app); 

And according to the author's message Warning: Unexpected character in input: '\' PHP analyzer did not recognize the \ that is used for namespace since PHP 5.3.0 , so clear that your version of PHP is incorrect. Try updating it. Check version with

 /usr/local/php5/bin/php -v 
+1
source

I assumed this was a problem with the PHP version and was right. Thanks for the other answers to the guys!

Here is a specific answer, if you have hosting from 1and1 / 1 & 1, create a .htaccess file in the root of your domain using this code in it

 AddHandler x-mapp-php6 .php 

Note: "php6" is mapped to PHP version 5.4 also note: if the file already has .htaccess, which probably is, just create a line at the beginning and insert this line of code. for example, my .htaccess file for the laravel 5 root domain looks like this: (thanks to the help of http://laravel.io/forum/03-21-2014-laravel-production-deployment-on-1and1 )

 <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On AddHandler x-mapp-php6 .php # Redirect Trailing Slashes... RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ /index.php [L] </IfModule> 

Note the / added to the string RewriteRule ^ ... as well as the php6 part

should be fine, see the link for your help here

https://help.1and1.com/hosting-c37630/scripts-and-programming-languages-c85099/php-c37728/manually-set-the-version-of-php-using-an-htaccess-file-a614325. html

0
source

Source: https://habr.com/ru/post/1487984/


All Articles