How to declare a dependency for another package in a package?

I'm trying to use the bundle inside the bundle, but for some reason this is failig.

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

it seems to work so far. But I cannot figure out how to declare another dependency in "myname / mybundle".

I tried the following in the composer.json myname / mybundle file, but none of them worked :(

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

and

"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"
}

when i rum composer.phar updateall i get is

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

+5
source share
2 answers

Ok i found the answer here

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

This is too bad ... but now, at least, I know where to put my dependency (in the root composer.json file)

+5
source

, , . 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);

        // ...
    }
}
0

All Articles