作曲家脚本使用较旧的php版本 [英] composer scripts use older php version

查看:120
本文介绍了作曲家脚本使用较旧的php版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在webfaction上托管了越来越多的网站.很棒的供应商!我遇到了一些我认为与Linux有关的问题.希望有人能帮忙.

I host more and more sites on webfaction. Great provider! I ran into some problems though which I think are Linux related. Hope someone can help.

SSH命令php -v默认为旧版本的php,因此我在.bash_profile中创建了一个别名:

SSH command php -v defaults to an older version of php, So I created an alias in my .bash_profile:

alias composer="php70 $HOME/composer.phar"
alias php="php70"

现在我执行php -v时,它将返回PHP 7.0.到目前为止,一切都很好!

When I preform a php -v now it returns PHP 7.0. So far, so good!

PHP 7.0.0 (cli) (built: Dec  4 2015 12:58:58) ( NTS )

但是现在当我运行作曲家安装并将php -v放入脚本中的composer.json文件中的脚本-> post-install-cmd列表中时:

But now when I run a composer install and put a php -v in the scripts -> post-install-cmd list in my composer.json file:

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*"
},
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~4.0",
    "phpspec/phpspec": "~2.1"
},
"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ]
},
"scripts": {
    "post-install-cmd": [
        "php -v",
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "pre-update-cmd": [
        "php artisan clear-compiled"
    ],
    "post-update-cmd": [
        "php artisan optimize"
    ],
    "post-root-package-install": [
        "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ]
},
"config": {
    "preferred-install": "dist"
}

}

现在tt再次返回旧的php版本,请参见以下屏幕截图:

Now tt returns the old php version again, see this screenshot:

也许对你们来说这似乎完全合乎逻辑,但是我被困在这里.

Maybe this seems completely logic to you guys/girls, but I'm stuck here.

推荐答案

好吧,Composer不会使用您的别名来执行PHP.

Well, Composer doesn't use your alias to execute PHP.

您可以在composer.json中使用php70 -v,但最好使用 将较新的PHP版本符号链接到/bin/php,以便Composer可以选择它:

You could use php70 -v in composer.json, but its better to symlink the newer PHP version to /bin/php, so that Composer can pick it up:

创建一个~/bin文件夹

mkdir ~/bin

然后将新的PHP版本/usr/local/bin/php70链接到just ~/bin/php

Then symlink the newer PHP version /usr/local/bin/php70 to just~/bin/php

ln -s /usr/local/bin/php70 ~/bin/php

最后,将此行添加到.bash_profile,以将该文件夹附加到环境变量PATH.

Finally, add this line to .bash_profile to append this folder to your environment variable PATH.

export PATH="$HOME/bin:$PATH"

这篇关于作曲家脚本使用较旧的php版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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