2012-09-14 34 views
5

我想在Bundle中使用一個Bundle,但不知何故它是failig。如何正確地聲明捆綁包中另一個捆綁軟件的依賴關係?

"repositories": [ 
    { 
     "type": "vcs", 
     "url": "https://github.com/myname/mybundle" 
    } 
], 
"require": { 
    "php": ">=5.3.3", 
    "symfony/symfony": "2.1.*", 
    (...) 
    "myname/mybundle": "*" 
}, 

這似乎工作到目前爲止。但我無法弄清楚如何在「myname/mybundle」中聲明另一個依賴關係。

我試着在MYNAME/mybundle的composer.json文件中的下列但他們沒有工作:(

"repositories": [ 
    { 
     "type": "vcs", 
     "url": "url": "https://github.com/drymek/PheanstalkBundle" 
    } 
], 
"require": { 
    (...) 
    "drymek/PheanstalkBundle": "dev-master" 
} 

"repositories": [ 
    { 
     "type": "package", 
     "package": { 
      "name": "drymek/PheanstalkBundle", 
      "version": "dev-master", 
      "source": { 
       "url": "https://github.com/drymek/PheanstalkBundle.git", 
       "type": "git", 
       "reference": "master" 
      } 
     } 
    } 
], 
"require": { 
    (...) 
    "drymek/PheanstalkBundle": "dev-master" 
} 

當我朗姆酒composer.phar update我得到的是

- myname/mybundle dev-master requires drymek/pheanstalkbundle dev-master -> no matching package found.

+0

第二庫是從https: //github.com/digitalpioneers/pheanstalk或在https://github.com/drymek/PheanstalkBundle? –

+0

哎呦對不起drymek/PheanstalkBundle ...現在糾正它;) – Senad

回答

5

好的我找到了答案here

它聲明:Repositories are not resolved recursively. You can only add them to your main composer.json. Repository declarations of dependencies' composer.jsons are ignored

這太糟糕了......但現在至少我知道在哪裏把我的dependeny(根composer.json文件)

+0

這意味着作曲家不是**,比舊的deps文件好得多。我懷疑是遞歸地解決它是一個壞主意,或者只是他們還沒有實現這一點。 – Jens

+0

至少你可以考慮你的bundle的composer.json文件。我在類似的情況下面臨一個非常奇怪的問題。我的項目需要檢索一些自定義zip包,在這些包中,composer.json文件定義了其他需求。這些需求的存儲庫在根composer.json文件中聲明。 問題是,壓縮文件下載後,解壓縮並放置在供應商目錄中,作曲家完全忽略其composer.json,其中包的需求被定義...任何想法? –

+0

hey giuliano,對不起,但我不知道這個答案......但正如我看到你在你的線程上得到了一個答案。 ;)http://stackoverflow.com/questions/15023126/composer-ignoring-zip-dependecies-composer-json-file – Senad

0

對於捆綁的依賴關係,請參閱我的圖書館https://github.com/AshleyDawson/MultiBundle。作爲一個例子,擴展MultiBundle並實現getBundles()方法,像這樣:

<?php 

namespace Acme\MyBundle; 

use AshleyDawson\MultiBundle\AbstractMultiBundle; 

class AcmeMyBundle extends AbstractMultiBundle 
{ 
    /** 
     * Optional: define a protected constructor to stop instantiation  outside of registerInto() 
     */ 
    protected function __construct() 
    { 

    } 

    /** 
    * Define bundles that this bundle depends on 
    */ 
    protected static function getBundles() 
    { 
     return array(
      new Acme\FooBundle\AcmeFooBundle(), 
      new Acme\BarBundle\AcmeBarBundle(), 
     ); 
    } 
} 

然後在AppKernel寄存器束,它的依存關係:

// app/AppKernel.php 

// ... 

class AppKernel extends Kernel 
{ 
    // ... 

    public function registerBundles() 
    { 
     $bundles = array(
      // ..., 
     ); 

     // Register my bundle and its dependencies 
     \Acme\MyBundle\AcmeMyBundle::registerInto($bundles); 

     // ... 
    } 
} 
相關問題