亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

怎么用composer開發自己的php擴展包

發布時間:2020-12-09 11:05:08 來源:億速云 閱讀:529 作者:小新 欄目:軟件技術

小編給大家分享一下怎么用composer開發自己的php擴展包,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

composer 是PHP用來管理依賴關系的工具

開發流程

初始化自己的擴展包 composer init

$ composer init
  Welcome to the Composer config generator
  
This command will guide you through creating your composer.json config.
Package name (<vendor>/<name>) [administrator/self_composer]: victor/composer-self //包名稱-不能大寫,否則無效 
Description []: composer-self package //描述
Author [victor24680 <490319148@qq.com>, 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]? n //是否定義依賴關系
Would you like to define your dev dependencies (require-dev) interactively [yes]? n
{
    "name": "victor/composer-self",
    "description": "This is a composer-send package",
    "type": "victor",
    "license": "MIT",
    "authors": [
        {
            "name": "victor24680",
            "email": "490319148@qq.com"
        }
    ],
    "minimum-stability": "dev",
    "require": {}
}
Do you confirm generation [yes]? yes

修改自己包的依賴關系,修改內容如下

{
    "name": "victor/sendtool-package",
    "description": "sendtool package",
    "type": "victor",
    "license": "MIT",
    "authors": [
        {
            "name": "victor24680",
            "email": "490319148@qq.com"
        }
    ],
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.6" //php版本要求
    },
    "autoload": {
        "psr-4": { //加載規范
            "App\\": "src/App",
            "Contract\\": "src/Contract"
        }
    }
}

編寫好源碼 見:https://github.com/victor24680/self-composer/tree/master/src

安裝測試 composer install

$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Content-Length mismatch, received 37487 bytes out of the expected 2005372
http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Nothing to install or update
Writing lock file
Generating autoload files

GitHub上創建composer-self倉庫

git init
git add .
git commit -m "初始自己的組件庫"
git remote add origin https://github.com/victor24680/self-composer.git
git push origin master

Packagist 上提交自己的github創建的composer-self倉庫地址

注冊地址:https://packagist.org/,提交成功之后,就可以開始下面的測試

測試 ,A目錄代表項目根目錄

創建一個A目錄,然后在項目根目錄下執行:composer require victor24680/self-composer dev-master

$ composer require victor24680/self-composer dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing victor24680/self-composer (dev-master 0935c75): Cloning 0935c75eda from cache
Writing lock file
Generating autoload files
<?php
#項目根目錄/index.php
include "vendor/autoload.php";
use App\CommonInfo;
use App\Zn;
$app=new CommonInfo(new Zn());
echo $app->msg('小明','隔壁老王在偷吃!!!');
//輸出:【站內消息】發送給:小明|發送內容:【普通消息】隔壁老王在偷吃!!!

以上是“怎么用composer開發自己的php擴展包”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

静乐县| 荔波县| 屏东市| 定结县| 西安市| 高雄市| 武平县| 连江县| 汉沽区| 青浦区| 扶余县| 平邑县| 太原市| 崇阳县| 房山区| 化州市| 西城区| 三台县| 定兴县| 邹城市| 读书| 杭锦后旗| 建瓯市| 岑巩县| 南江县| 灵武市| 合水县| 景宁| 临夏县| 禹城市| 佛冈县| 宁南县| 麻江县| 万宁市| 闽侯县| 乐都县| 温宿县| 辰溪县| 太湖县| 叶城县| 张家港市|