composer - 制作一个自己的composer包

github创建一个空的项目

不在赘述可以百度

做自己的包,给大家展示一下我的demo

在这里插入图片描述

初始化自己的包

根目录下执行 composer init 会让你自己填写内容,不知道怎么写的可以去百度

test git:(master)composer init


  Welcome to the Composer config generator



This command will guide you through creating your composer.json config.

Package name (<vendor>/<name>) [zouzhanhao/test]:
Description []: 测试
Author [, n to skip]: zouzhanhao <1021314274@qq.com>
Minimum Stability []: dev
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:
Would you like to define your dev dependencies (require-dev) interactively [yes]?
Search for a package:

{
    "name": "zouzhanhao/test",
    "description": "测试",
    "type": "library",
    "license": "MIT",
    "authors": [
        {
            "name": "zouzhanhao",
            "email": "1021314274@qq.com"
        }
    ],
    "minimum-stability": "dev",
    "require": {}
}

Do you confirm generation [yes]? yes
Would you like the vendor directory added to your .gitignore [yes]? ye
Please answer yes, y, no, or n.
Would you like the vendor directory added to your .gitignore [yes]? yes
生成的json需要加入自动加载
    "autoload": {
        "psr-4":{
            "test\\":"src"
        }
    }

加入之后的样子,这里要注意的是自动加载的路径 遵循psr-4标准

在这里插入图片描述

测试的话,你可以直接composer install 测试 ,这里用空在写
关联github 我用的SSH方式,
test git init
已初始化空的 Git 仓库于 /WWW/test/.git/
➜  test git:(master)git add .test git:(master)git commit -m 'first'
[master(根提交) 6686410] first
 5 files changed, 85 insertions(+)
 create mode 100644 .idea/misc.xml
 create mode 100644 .idea/modules.xml
 create mode 100644 .idea/test2.iml
 create mode 100644 .idea/workspace.xml
 create mode 100644 src/test.php
➜  test git:(master) git remote add origin git@github.com:1021314274/test.git
➜  test git:(master) git push -u origin master
枚举对象: 9, 完成.
对象计数中: 100% (9/9), 完成.
使用 4 个线程进行压缩
压缩对象中: 100% (8/8), 完成.
写入对象中: 100% (9/9), 1.80 KiB | 368.00 KiB/s, 完成.
总共 9 (差异 0),复用 0 (差异 0)
To github.com:1021314274/test.git
 * [new branch]      master -> master
分支 'master' 设置为跟踪来自 'origin' 的远程分支 'master'
提交包

packaglist
在这里插入图片描述

显示submit 表示包没有问题,直接提交就行了
在这里插入图片描述

包生成好了,但是没有版本 你直接composer是不会成功的,所以需要生成版本
git tag v1.0.0
git push --tag
最后找一个项目 composer require zouzhanhao/test 完事
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

想秃头的小邹

您的鼓励将是支持我的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值