2012-09-14 33 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); 

     // ... 
    } 
} 
相关问题