点击了解[CRMEB多商户](http://github.crmeb.net/u/meng) 其他开源项目源码 :[了解更多](http://github.crmeb.net/u/lanlan)
小姐姐二维码
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210421102423106.png)
一. 在gitee上创建一个仓库,这里就不详细赘述应该都会的,地址:https://gitee.com。
二. 在本地将仓库拉去下来。
1. 创建文件夹,然后克隆下来
2. 直接在工作目录下执行一下命令
```shell
mkdir sms #sms 是你想创建的文件夹名称
cd sms
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/
git push -u origin master
```
三. composer包的制作
1. 在刚才创建的文件夹下执行 `composer init`
```shell
#初始化一个composer包
composer init
Welcome to the Composer config generator
This command will guide you through creating your composer.json config.
#给你的包取过名字
Package name (
#给你的包做个简短的介绍
Description []: 短sms
#备注包的作者信息
Author [qinii <[email protected]>, n to skip]:
#包的最低稳定版本 给个dev或跳过
Minimum Stability []:
#包的封装类型 选择 库
Package Type (e.g. library, project, metapackage, composer-plugin) []: library
#包的授权协议 开源协议
License []: MIT
Define your dependencies.
#是否需要添加其他的依赖库,我选择是
Would you like to define your dependencies (require) interactively [yes]? yes
#这里搜索你需要依赖的库的名称
Search for a package: php
Warning from https://mirrors.aliyun.com/composer: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
#输入依赖库的要求 我输入 >=7.0
Enter the version constraint to require (or leave blank to use the latest version): >=7.0
#不需要其他依赖了 以下几项直接回车
Search for a package:
Would you like to define your dev dependencies (require-dev) interactively [yes]?
Search for a package:
{
"name": "qinii/sms",
"description": "sms",
"type": "l",
"require": {
"php": ">=7.0"
},
"license": "MIT",
"authors": [
{
"name": "qinii",
"email": "[email protected]"
}
]
}
#是否创建 composer.json 文件
Do you confirm generation [yes]? yes
#是否将vendor文件夹加入到忽略文件中去
Would you like the vendor directory added to your .gitignore [yes]? yes
#是安装相关的依赖库
Would you like to install dependencies now [yes]?
```
2. 编辑`composer.json`增加指定文件夹路径,别忽略上面的逗号
```shell
{
"name": "qinii/sms",
"description": "sms",
"type": "l",
"require": {
"php": ">=7.0"
},
"license": "MIT",
"authors": [
{
"name": "qinii",
"email": "[email protected]"
}
],
"autoload":{
"psr-4":{
"Qinii\\":"src/"
}
}
}
```
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210421114430629.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjY3MzQ0OA==,size_16,color_FFFFFF,t_70)
3. 命令行执行 `composer dump-autoload` 更新一下composer文件
4. 创建`src`文件夹,创建 `src/index.php`
```php
namespace Qinii;
class Index
{
public function index()
{
echo '如果看到我,说明你成功了';
}
}
```
创建`sms/index.php`
```php
require "vendor/autoload.php";
$index = new Qinii\Index();
$index->index();
```
5. 在当前目录执行一下`php index.php`,出现刚才写的就说明包是没问题的;
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210421122401940.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjY3MzQ0OA==,size_16,color_FFFFFF,t_70)
6. 将包全部上传
```shell
git add .
git commit -m 'test‘
git push
```
四. 提交到 composer
7. 进入 [composer](https://packagist.org) 官网
8. 登陆个人账户,选择右上角的 submit 按钮
9. 填写刚才的仓库地址,点击 check
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210421141906248.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjY3MzQ0OA==,size_16,color_FFFFFF,t_70)
10. 检测完毕后,上传就好了。
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210421142004420.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjY3MzQ0OA==,size_16,color_FFFFFF,t_70)
这里用的是gitee的仓库,如果要用github也是只需要更一下仓库地址就行了