问题
I'm running into issues installing Laravel 4... I am following the instructions posted here:
http://badubizzle.blogspot.com/2013/01/setting-up-laravel-4-on-webfaction.html
My host allows multiple versions of PHP to run at the same time, so running the command php
will run php 5.2.17 on whatever you specify next. I know you need greater than php 5.3 to run Laravel 4, so I am using php 5.4 to do so. I can either specifically type php54
to run the command under php 5.4, or an alias can be made in the .bash_profile to do so just when typing php, which is what I did.
Now, when I run the command php -v
, I get the following:
PHP 5.4.16 (cli) (built: Jul 24 2013 07:46:20)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with the ionCube PHP Loader v4.2.1, Copyright (c) 2002-2012, by ionCube Ltd.
The reason I did that was because when using composer, it seems that a lot of the commands it runs, it finds in the laravel files that are downloaded, and they all start with php
, instead of php54
, so I figured by making the alias, I should be fine, right? Wrong.
When I run this line:
php ~/composer.phar install
The system gets a bunch of files (like it should), and then it gets to this error:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/apps/laravel-master/artisan on line 46
Parse error: syntax error, unexpected T_STRING in /home/apps/laravel-master/artisan on line 46
Script php artisan optimize handling the post-install-cmd event returned with an error
When I research this error, everything I see says that it's an error of not running a high enough PHP version, and that you need to run php54
or something. I am doing that, and I'm still getting this error! Any ideas here? This REALLY has me stumped and I'm getting super frustrated. I would really appreciate any help anyone can offer!!
EDIT
I have tried following Laravel's documentation and have run into the same issue once I run the composer create-project laravel/laravel your-project-name --prefer-dist
command - it runs for a while, and then gets to the parse error. I really have no idea what's wrong here!
回答1:
I can't comment directly on thinkers Answer (not enough rep it seems), but I can say that the answer he linked to isn't just about an alias and it works for me.
open composer.json, and you'll see that it's trying to run the php command during post-install, and it's just using the regular php, something like:
php artisan optimize
You need to change that to something like:
/opt/php54/bin/php artisan optimize
Or whatever the path is. Composer, when reading the json file, doesn't really seem to care what your alias is. At least it didn't on the shared server I installed Laravel on.
回答2:
It seems a common problem on shared hosting when paths are not set properly. I already posted a solution here, maybe it works for you also.
来源:https://stackoverflow.com/questions/18127347/laravel-4-composer-install-fails-every-time-even-though-im-using-php-5-4