Centos 安装 composer
curl -sS https://getcomposer.org/installer | php
# 把composer.phar移动到环境下让其变成可执行
mv composer.phar /usr/bin/composer
chmod +x /usr/bin/composer
# 测试
composer -V
# 输出:Composer version 1.8.4 2019-02-11 10:52:10
init(初始化)
该命令用于创建 composer.json 文件,并进行基础信息配置:
$ composer init
可以配置Package name、Description、Author、Minimum、Package Type、License、dependencies 及 dev dependencies 信息。
完成后配置文件内容如下:
{
"name": "touge/oss-media",
"description": "description...",
"type": "library",
"keywords": ["laravel-admin", "extension"],
"homepage": "https://github.com/touge/oss-media",
"license": "MIT",
"authors": [
{
"name": "Nick Yuan",
"email": "lon.y@qq.com"
}
],
"require": {}
}
search(搜索)
根据名称搜索相关的包,成功后会列出符合的相关包的信息,本处以搜索 monolog 为例:
$ composer search touge
touge/scaffold
touge/oss-media description...
touge/modules
touge/laravel-jwt-auth description...
touge/laravel-dict
touge/laravel-admin-overwrite description...
touge/laravel-admin-ext-media description...
touge/laravel-admin-examination 九育教育考试系统,依赖主系统
touge/elfinder-media laravel-admin elfinder media extension
touge/ckeditor laravel admin extension ckeditor
verbb/super-table Super-charge your Craft workflow with Super Table. Use it to group fields together or build complex Matrix-in-Matrix solutions.
spatie/laravel-varnish Making Varnish and Laravel play nice together
bryglen/yii2-apns-gcm Yii 2 Apns and Gcm together
acquia/orca A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build
yiiext/activerecord-relation-behavior Inspired by and put together the awesomeness of many yii extensions that aim to improve saving of related records. Comes with 100% test coverage and well structured and clean code so it can savely be used in enterprise production enviroment.
show(详情)
根据包的名称,列出包的相关信息,本处以查看 touge/oss-meida 为例:
name : touge/oss-media
descrip. : description...
keywords : extension, laravel-admin
versions : dev-master, v1.0.0, v0.1.6
latest : v1.0.0
type : library
license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
source : [git] https://github.com/touge/oss-media.git 8b76168840a08370018090da1af3455ffdaa67ac
dist : [zip] https://api.github.com/repos/touge/oss-media/zipball/8b76168840a08370018090da1af3455ffdaa67ac 8b76168840a08370018090da1af3455ffdaa67ac
names : touge/oss-media
autoload
psr-4
Touge\OssMedia\ => src/
requires
php >=7.0.0
encore/laravel-admin ~1.6
aliyuncs/oss-sdk-php ^2.3
guzzlehttp/guzzle ^6.3
requires (dev)
phpunit/phpunit ~6.0
想查看更多信息,就亲自将该命令复制到命令行执行吧。
install (安装)
我们先在 composer.json 配置require中添加一个 touge/oss-media 依赖库,如下:
"require": {
"touge/oss-media": "1.21.*",
}
然后通过如下命令进行安装依赖
$ composer install
update (更新)
如果我们新增或者删除了某个依赖,可以通过如下命令进行更新
$ composer update
require (申明依赖)
我们也可以用命令直接添加依赖,执行该命令后将自动下载,命令如下:
$ composer require touge/oss-media
网友评论