Search code examples
zend-frameworkcomposer-php

Installing multiple packages with composer?


I am trying to install the latest version of Zend Framework 2 with composer and also install at least one other package at the same time. The other package is another Zend Framework package. The two packages are: zendframework/zendframework zendframework/zendservice-twitter

I added zendframework/zendservice-twitter to the require section of that file. It doesn't look like there is any other section to use to install multiple packages in the same directory tree. But when I try to add zendframework/zendservice-twitter to the require section of the composer.json file, it tells me that zendframework/zend-uri is required. But zendframework/zend-uri is installed by the zendframework/zendframework package. It is listed in the replace section of that composer.json file. So apparently the replace section is not the place to add other packages that need to be installed. But you can't have multiple composer.json files in the same directory either, so is it even possible to install Zend Framework 2 and ZendServiceTwitter in the same installation with composer?

When I download a package as a zip file from https://packages.zendframework.com/#composer, I get a composer.json file in the zip file, but it does not have the same repository setting that it says to use at https://packages.zendframework.com. So I am not sure if that composer.json file is intended to be edited in order to upgrade or reinstall.

Isn't there some way to tell composer that this is a circular dependency?


Solution

  • I don't see the circular dependency. The twitter package requires zend-uri, and zend-uri is provided by the main Zend Framework package that you've already installed.

    I just tried this out on a fresh checkout of the skeleton app and it worked fine. All I did was add the twitter package to the require section of my composer.json:

    "require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "2.3.*",
        "zendframework/zendservice-twitter": "~2.1.0"
    }
    

    (2.1.0 is the latest version of it at the moment.) You don't need to touch the replace section.