Laravel 4-即使我使用的是PHP 5.4,Composer每次安装都会失败 [英] Laravel 4 - Composer Install fails every time, even though I'm using PHP 5.4

查看:111
本文介绍了Laravel 4-即使我使用的是PHP 5.4,Composer每次安装都会失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在安装Laravel 4时遇到问题...我正在按照此处发布的说明进行操作:

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

我的主机允许同时运行多个版本的PHP,因此运行命令php将在接下来指定的内容上运行php 5.2.17.我知道您需要大于php 5.3才能运行Laravel 4,因此我正在使用php 5.4来执行此操作.我可以专门键入php54在php 5.4下运行该命令,也可以在.bash_profile中创建一个别名,以便在键入php时这样做,这就是我所做的.

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.

现在,当我运行命令php -v时,我得到以下信息:

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.

之所以这样做,是因为在使用composer时,它似乎运行了很多命令,它们在下载的laravel文件中找到,并且它们都以php而不是php54开头,所以我想通了别名,我应该没事吧?不对.

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.

运行此行时:

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

当我研究此错误时,我看到的一切都表明未运行足够高的PHP版本是一个错误,并且您需要运行php54或类似的东西.我正在这样做,但仍然出现此错误!这里有什么想法吗?这真的让我感到难过,我感到非常沮丧.我真的很感激任何人都可以提供的帮助!

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!!

编辑

我尝试遵循Laravel的文档,并且在我运行composer create-project laravel/laravel your-project-name --prefer-dist命令后遇到了同样的问题-它运行了一段时间,然后出现了解析错误.我真的不知道这是怎么回事!

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!

推荐答案

我无法直接对思想家的答案进行评论(似乎没有足够的代表),但是我可以说他链接到的答案不只是一个别名,它对我有用.

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.

打开composer.json,您会看到它正在尝试在安装后运行php命令,并且仅使用常规php,例如:

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

您需要将其更改为:

/opt/php54/bin/php artisan optimize

或者无论路径是什么.当阅读json文件时,Composer似乎并不真正在乎您的别名是什么.至少它不在我安装了Laravel的共享服务器上.

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.

这篇关于Laravel 4-即使我使用的是PHP 5.4,Composer每次安装都会失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆