簡體   English   中英

ZF2模塊和外部依賴項

[英]ZF2 Modules & external dependencies

我不清楚在計划分發的自定義模塊中包括外部庫的最佳實踐是什么。

通常,我會將外部庫放在應用程序的供應商目錄下。 但是我想確保在分發自定義模塊時滿足所有依賴關系(即,我不想強​​迫人們手動將依賴關系下載到其應用程序的供應商目錄中)。

按照以下說明,在模塊目錄下包括一個供應商目錄是正確的做法嗎?

/application_dir
     /vendor
     /module
          /my_module
              /vendor

使用作曲家,您可以在這里找到文檔:

作曲家文檔

基本上,您將在應用程序的根目錄中修改文件composer.json,並在require部分中添加依賴項:

{
    "name": "zendframework/skeleton-application",
    "description": "Skeleton Application for ZF2",
    "license": "BSD-3-Clause",
    "keywords": [
        "framework",
        "zf2"
    ],
    "homepage": "http://framework.zend.com/",
    "require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "2.2.*",
        "doctrine/common": "dev-master",
        "zendframework/zendpdf": "2.*",
        "zendframework/zendservice-recaptcha": "2.*",
        "thiagoalessio/tesseract_ocr": ">= 0.1.2",
        "zf-commons/zfc-user": "dev-master"
        // add your requirements here**
    }
}

如果依賴項位於私有github存儲庫上,則可以這樣添加:

{
    "require": {
        "vendor/my-private-repo": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "git@bitbucket.org:vendor/my-private-repo.git"
        }
    ]
}

完成添加后,請不要忘記進行composer.phar更新。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM