<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # **建立自己的composer包** composer 包的平臺:[packagist.org](https://packagist.org/),這里面包含了大量的優秀的安裝包 **1、創建自己的github倉庫** 點擊 [New repository](https://github.com/new)創建自己的github倉庫,命名為test ![](https://img.kancloud.cn/b2/e0/b2e0a81d23f4cf211196a99ddf07dddd_268x260.png) **2、克隆項目** git定位到D:\下鍵入: ``` git clone git@github.com:lichihua/test.git ``` 克隆后:D:\目錄下會生成D:\test目錄 **3、創建 Composer 配置文件** 在項目根目錄`D:\test`創建 Composer 配置文件 composer.json,可以使用命令`compser init`創建也可以手動創建,最終文件內容大體如下: ~~~ { // "name": "一般有供應方名或者作者名/項目名", //github的用戶名(個人或團體)+項目名 "name": "lichihua/test", //發布第三方包時,packagist包名與此名一致 composer require lichihua/test "description": "該項目描述", "authors": [ { "name": "作者名" } ], "license": "MIT", "require": { "php": ">=5.4" }, "autoload": { "psr-0": { //根命名空間最好是項目名或【供應方名或者作者名】/項目名 方便開發者記憶 不過項目名代下劃線如think_test 這種可以改成 thinktest "Lichihua\\Test\\": "src/" //use Lichihua\Test\... } } } ~~~ **4、編寫及測試文件** 定義好以后在composer.json同文件下的src下編寫測試類,詳情請參照`composer自動加載講解`章節 >[danger]壓縮源(src)文件,生成壓縮包到(dest),dest一般和src配對出現 目錄結構參照: ~~~ D:/ ├─test 應用目錄(www) │ ├─composer.json composer 定義文件 │ ├─.gitignore │ ├─README.md README 文件 │ ├─src 項目目錄 │ │ ├─Lichihua 目錄 │ │ │ ├─Test 目錄 │ │ │ │ ├─User.php User類測試文件 │ │ │ │ ├─Tools.php Tools類測試文件 │ │ │ │ └─ ... │ │ │ │ │ │ │ └─ ... │ │ │ │ │ ├─Client.php 測試文件1 │ │ ├─Service.php 測試文件2 │ │ └─ ... 更多類文件 │ ├─index.php 入口文件測試編寫的類 │ │ │ └─... │ ├─... ~~~ 使用 composer install 或者 composer update 更新下數據 測試是否加載成功 **5、添加忽略文件** 然后編輯.gitignore文件,將lock文件放到忽略文件中,如下: ``` /vendor/ composer.lock ``` **6、上傳到github** 具體參考git的文檔 ``` git add . git reset HEAD . //回退 git add的內容 git commit -m "提交說明" git push origin master ``` **7、提交到[packagist](https://packagist.org/packages/submit)這個網站上** 點加submit Repository URL (Git/Svn/Hg)下的文本框里填寫github的地址 `git@github.com:lichihua/test.git`,再點擊check ,檢測成功點擊提交則成功 ![](https://img.kancloud.cn/5c/4f/5c4f22d9d8958b1d2402cb9837754ce1_833x154.png) ![](https://img.kancloud.cn/ce/6e/ce6e8785c0743ae2a6aa81062161803c_1282x279.png) 設置代碼更新,同時能讓[packagist.org](http://packagist.org/)自動更新(默認是自動更新的) 如果未綁定,可以這樣設置:"settings" -> “Webhooks” -> "Add webhook" -> 1. Payload URL填寫:“[packagist.org/api/github”](https://packagist.org/api/github%E2%80%9D) 2. Content type填寫:“application/json” 3. Secret填寫:“packagist提供的token” 4. 其他的默認即可 5. 點擊“Add webhook” 完成。 ![](https://img.kancloud.cn/11/be/11beab3d270795bf300658fb044ccdb2_1304x515.png) **8、另外一個項目中,加載這個剛建的包** ``` composer require lichihua/test ``` 另外,加載這個包`composer require lichihua/test ` 測試不能成功提示沒有找到版本,這是因為沒有打標簽tag 沒有打 tag 的要指定 dev,完整命令`composer require "lichihua/test @dev"` git頁面我們切換到test項目根目錄,提交修改,打一個v0.1的tag,然后提交tag到遠程github倉庫 git push \<遠程主機名> \<本地分支名> \<遠程分支名> tagName ``` git tag -a v0.1 -m "第一個版本" git push origin v0.1 ``` github當前項目里點擊release,發布一個版本 進入后在點擊右側的[Draft a new release](https://github.com/lichihua/test/releases/new))按鈕 有三個文本框 分別是版本、版本說明標題、版本說明 填寫好以后點擊Publish release提交 參考[https://www.jianshu.com/p/280acb6b0b22](https://www.jianshu.com/p/280acb6b0b22) ![](https://img.kancloud.cn/49/05/49053f693033fa3fb98e8feb3fc84ac5_1039x434.png) ![](https://img.kancloud.cn/56/b6/56b688585e6863be93cfd565ee081ca7_977x594.png) 再次`composer require lichihua/test`目錄結果 ~~~ composer.json vender ├─composer ├─lichihua │ ├─test 應用目錄(www) │ │ ├─composer.json composer 定義文件 │ │ ├─.gitignore │ │ ├─README.md README 文件 │ │ ├─src 項目目錄 │ │ │ ├─Lichihua 目錄 │ │ │ │ ├─Test 目錄 │ │ │ │ │ ├─User.php User類測試文件 │ │ │ │ │ ├─Tools.php Tools類測試文件 │ │ │ │ │ └─ ... │ │ │ │ │ │ │ │ │ └─ ... │ │ │ │ │ │ │ ├─Client.php 測試文件1 │ │ │ ├─Service.php 測試文件2 │ │ │ └─ ... 更多類文件 │ │ ├─index.php 入口文件測試編寫的類 │ │ │ │ │ └─... │ │ │ ├─test2 │ │ │ ├─... │ ├─autoload.php │ └─... ~~~ ``` { "require": { "lichihua/test": "^0.2.0" } } ``` `D:\phpstudy_pro\WWW\wwwdemo1.com\vendor\lichihua\test\composer.json` ``` { ... "autoload": { "psr-4": { "Dash\\tools\\":"src" } } } ``` >psr-4的規則:"root命名空間\\":"起始路徑", root命名空間:Dash\\tools\\ 起始路徑:src 對應文件的路徑:起始路徑+ [額外路徑] + 類文件(必須與類名一致) 即:src+church+TestClass1.php 使用時 use root命名空間[\額外路徑]\類名 new \root命名空間[\額外路徑]\類名() `D:\phpstudy_pro\WWW\www.demo1.com\vendor\lichihua\test\src\church\TestClass1.php` ``` <?php namespace Dash\tools\church; class TestClass1{ public function show(){ echo 'hello'; } } ``` `D:\phpstudy_pro\WWW\www.demo1.com\index.php` ``` <?php ini_set('display_errors', 1); error_reporting(E_ALL); include 'vendor/autoload.php'; $a= new \Dash\tools\church\TestClass1(); var_dump($a); ``` >[info]那么可不可以不上傳到 讓composer直接獲取到github倉庫的插件包呢? ~~~ "repositories": [ { "type": "vcs", "url": "https://github.com/user/project" } ] ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看