服务器环境下创建自己的项目文件
初始化composer
打开cmd 窗口,cd 到 backrestore 执行 composer init 命令
D:phpStudyWWWackrestore>composer init
Welcome to the Composer config generator This command will guide you through creating your composer.json config. Package name (<vendor>/<name>) [administrator/backrestore]: xue-y/backrestore Description []: mysql Backup and restore // 项目描述可以不写 Author [xue-y <1922527784@qq.com>, n to skip]: // 这里跳过使用默认 Minimum Stability []: Package Type (e.g. library, project, metapackage, composer-plugin) []: License []: // 这个可以不填 Define your dependencies. Would you like to define your dependencies (require) interactively [yes]? y Search for a package: Would you like to define your dev dependencies (require-dev) interactively [yes]? y Search for a package: { "name": "xue-y/backrestore", "description": "mysql Backup and restore", "authors": [ { "name": "xue-y", "email": "1922527784@qq.com" } ], "require": {} } Do you confirm generation [yes]? y
这里完成composer 初始化工作,自动生成一下文件
编辑composer.json 文件
{
"repositories": { // 更改镜像源,国外的太慢
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
},
"name": "xue-y/backrestore",
"description": "mysql Backup and restore",
"license": "Apache-2.0",
"minimum-stability":"stable",
"authors": [
{
"name": "xue-y",
"email": "1922527784@qq.com"
}
],
"require": {
"php": ">=5.0"
},
"autoload": { // 添加自动加载
"psr-4": {
"backup\": "backup/",
"import\": "import/"
}
}
}
执行 composer install
D:phpStudyWWWackrestore>composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
测试文件
创建git 仓库
创建后会跳转到下面这个页面,根据你的需要按命令操作
项目提交git
我这个项目现在不是一个存储库,所有先执行了一下 git init 初始化仓库
Administrator@Admin MINGW64 /d/phpStudy/WWW/backrestore
$ git init
Initialized empty Git repository in D:/phpStudy/WWW/backrestore/.git/
Administrator@Admin MINGW64 /d/phpStudy/WWW/backrestore (master)
$ git add README.md
Administrator@Admin MINGW64 /d/phpStudy/WWW/backrestore (master)
$ git commit -m '添加第一个测试文件'
[master (root-commit) d79b36b] 添加第一个测试文件
1 file changed, 76 insertions(+)
create mode 100644 README.md
Administrator@Admin MINGW64 /d/phpStudy/WWW/backrestore (master)
$ git remote add origin https://github.com/xue-y/backrestore.git
Administrator@Admin MINGW64 /d/phpStudy/WWW/backrestore (master)
$ git push -u origin master
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 1.57 KiB | 1.57 MiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote: https://github.com/xue-y/backrestore/pull/new/master
remote:
To https://github.com/xue-y/backrestore.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
添加标签
packgist 发布自己的包
git 复制自己项目的地址,登录上 packgist,点击提交(Submit)
设置自动更新包,需要确定授权 packagist,可以先退出登录,在使用 github 账号登录 packgist,点击授权并登录即可
我这里原来授权过,所有直接显示
如果第一次授权,点击添加 Add webhook
现在,完成一个包的整体发布!!!