Rootop 服务器运维与web架构

php安装composer命令并下载依赖

compose用的较少,记录下安装过程。
官网:https://getcomposer.org/download/

# 安装compose

[root@MiWiFi-R3P-srv ~]# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
[root@MiWiFi-R3P-srv ~]# php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
[root@MiWiFi-R3P-srv ~]# php composer-setup.php
[root@MiWiFi-R3P-srv ~]# php -r "unlink('composer-setup.php');"
[root@MiWiFi-R3P-srv ~]# mv composer.phar /usr/local/composer

# 更新compose

[root@MiWiFi-R3P-srv ~]# /usr/bin/composer self-update

# 切换国内镜像,提高下载速度, 选一个执行。

[root@MiWiFi-R3P-srv ~]# composer config -g repo.packagist composer https://packagist.phpcomposer.com
[root@MiWiFi-R3P-srv ~]# composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/
[root@MiWiFi-R3P-srv ~]# composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

# 安装依赖 2 种方式
1、根据composer.json自动下载

[root@MiWiFi-R3P-srv ~]# cat composer.json 

{
    "require": {
        "monolog/monolog": "1.2.*"
    }
}
[root@MiWiFi-R3P-srv ~]# composer install

2、手动安装

[root@MiWiFi-R3P-srv ~]# composer require redisent/redis

这两种方式都会将安装的代码放在当前路径下的vendor目录下

# 更多参数直接执行composer可以看到:

[root@MiWiFi-R3P-srv ~]# composer

参数含义可参考:https://www.runoob.com/w3cnote/composer-install-and-usage.html

原创文章,转载请注明。本文链接地址: http://www.rootop.org/pages/4714.html

赞赏

微信赞赏支付宝赞赏

作者:Venus

专注于 服务器运维与web架构 E-mail:venus#rootop.org

评论已关闭。