中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

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

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

怎么用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

资中县| 城口县| 青河县| 运城市| 承德县| 礼泉县| 辉南县| 赤壁市| 永年县| 姜堰市| 陕西省| 新闻| 广饶县| 夏津县| 双桥区| 黄骅市| 通许县| 蒙山县| 大渡口区| 安塞县| 白沙| 汉沽区| 邯郸县| 新竹市| 潞西市| 瑞金市| 阿鲁科尔沁旗| 布尔津县| 富蕴县| 庐江县| 吴堡县| 阳东县| 喀喇沁旗| 弥勒县| 舒城县| 墨脱县| 兴国县| 扶绥县| 石景山区| 高邮市| 衡南县|