composer / C扩展
最后更新于:2022-04-02 02:23:19
[TOC]
---
> packagist [包管理网站](https://packagist.org/packages/)
> [composer官网]()
---
## 发布自己的Composer
>参考网站[网址](https://www.greatcl.com/2016/09/02/create-your-first-composer-package/)
### 安装未发布版本
如果自制包没有发布在composer.json中写
`"minimum-stability": "dev",`
安装时使用命令
`composer require idcpj/talking_robot:dev-master`
### 配置 composer 自动更新
[官方教程](http://blog.csdn.net/xionggang1024/article/details/77162007)
### Composer.json配置文件说明
[官方说明](https://docs.phpcomposer.com/04-schema.html#composer.json)
```
{
"name": "meta/silk",
"description": "another e-commerce website",
"keywords": ["silk", "online shop", "good"],
"homepage": "http://www.xxx.com ",
"time": "2014-12-30",
"license": "MIT",
"authors": [{
"name": "Elvis Lim",
"email": "elvis@xxx.com",
"homepage": "http://www.xxx.com",
"role": "Engineer"
}],
"require": {
"monolog/monolog": "1.0.*@beta",
"acme/foo": "@dev"
},
"require-dev": {
"codeception/codeception": "2.0.0 "
},
"autoload": {
"psr-4": {
"Monolog\\": "src/",
"Vendor\\Namespace\\": ""
},
"psr-0": {
"Monolog\\": "src/",
"Vendor\\Namespace\\": "src/",
"Vendor_Namespace_": "src/"
}
}
}
```
## 使用composer
### 安装 composer
#### 全局安装
[各个版本的教程](https://pkg.phpcomposer.com/#how-to-install-composer)
centos
```
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
```
### 使用镜像
[中国全量镜像](https://pkg.phpcomposer.com/)
[阿里镜像](https://developer.aliyun.com/composer)
1. 在全局配置镜像(推荐)
在命令行中输入:
`composer config -g repo.packagist composer https://packagist.phpcomposer.com`
2. 修改项目镜像
在项目根目录
`composer config repo.packagist composer https://packagist.phpcomposer.com`
你也可以手动添加镜像地址到composer.json文件
```
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
```
3. 出现ssl 报错
参考此[网站](http://www.ituring.com.cn/article/261281)
### 初始化项目
如 `composer create-project easyswoole/app` 后在本地生成一个与 `github.com/easy-swoole/app`相同的项目
### 安装依赖
`composer install`
### 新增依赖
';