独自のcomposerプライベートパッケージを作成

2921 ワード

独自のcomposerプライベートパッケージを作成
gitlab上にプロジェクトcloneをローカルに作成する
git clone http://git.pandamonk.com/pandamonk/test.git
cd test

ディレクトリ構造
.
src
SayHello.php

SayHello.phpのファイル内容

composerを生成します.jsonファイル
//          ,   
composer init
//                 composer.json  
Welcome to the Composer config generator
This command will guide you through creating your composer.json config.
Package name (/) [root/composer-car]: pandamonk/hello
Description []: This a demo for build composer packagist .
Author [pandamonk , n to skip]:
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]? no
Would you like to define your dev dependencies (require-dev) interactively [yes]? no
{
"name": "pandamonk/hello",
"description": "This a demo for build composer packagist.",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "pandamonk ",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {}
}
Do you confirm generation [yes]? yes
Would you like the vendor directory added to your .gitignore [yes]? yes
//        
.
composer.json
src
SayHello.php

手動でcomposerを編集する必要があります.jsonファイル
{
    "name": "pandamonk/hello",
    "description": "This a demo for build composer packagist.",
    "type": "library",
    "license": "MIT",
    "authors": [
        {
            "name": "pandamonk ",
            "email": "[email protected]"
        }
    ],
    "minimum-stability": "dev",
    "require": {},
    "autoload": {
        "psr-4": {
            "Hello\\": "src/"
        }
    }
}

書き立てたcomposerパッケージを手動でテストします
//         
composer install
//     
.
composer.json
composer.lock
src
SayHello.php
vendor
autoload.php
composer
//                  test.php

作成したパッケージをgitlabに送信
             .gitignore      
verdor/*
composer.lock
    
git add .
git commit -m 'some commit'
git push
//      tag      
git tag 1.0.1 -a -m 'v1.0.1 release'
git push --tags