Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Your requirements could not be resolved to an installable set of packages

Sorry for duplication of this question with another one. I can't solve my problem.

I am working on a project based on Ratchet. I am trying to run the Push Integration example. So, in order to run, I should use composer to get some dependencies. I make a composer.json file like below:

{
    "autoload": {
        "psr-0": {
            "MyApp": "src"
        }
    },
    "require": {
        "cboden/ratchet": "0.3.*",
        "react/zmq": "0.2.*|0.3.*"
    }
}

When I execute composer on it, below error occurrs:

Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - react/zmq v0.3.0 requires ext-zmq * -> the requested PHP extension zmq is missing from your system.
    - react/zmq v0.2.0 requires ext-zmq * -> the requested PHP extension zmq is missing from your system.
    - Installation request for react/zmq 0.2.*|0.3.* -> satisfiable by react/zmq[v0.2.0, v0.3.0].

Below you can find composer.json of Ratchet and ZMQ:

ZMQ:

{
    "name": "react/zmq",
    "description": "ZeroMQ bindings for React.",
    "keywords": ["zmq", "zeromq"],
    "license": "MIT",
    "require": {
        "php": ">=5.4.0",
        "ext-zmq": "*",
        "evenement/evenement": "~2.0",
        "react/event-loop": "0.4.*"
    },
    "require-dev": {
        "ext-pcntl": "*"
    },
    "autoload": {
        "psr-0": { "React\\ZMQ": "src" }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "0.4-dev"
        }
    }
}

Ratchet:

{
    "name": "cboden/ratchet"
  , "type": "library"
  , "description": "PHP WebSocket library"
  , "keywords": ["WebSockets", "Server", "Ratchet", "Sockets"]
  , "homepage": "http://socketo.me"
  , "license": "MIT"
  , "authors": [
        {
            "name": "Chris Boden"
          , "email": "[email protected]"
          , "role": "Developer"
        }
    ]
  , "support": {
        "forum": "https://groups.google.com/forum/#!forum/ratchet-php"
      , "issues": "https://github.com/ratchetphp/Ratchet/issues"
      , "irc": "irc://irc.freenode.org/reactphp"
    }
  , "autoload": {
        "psr-0": {
            "Ratchet": "src"
        }
    }
  , "require": {
        "php": ">=5.3.9"
      , "react/socket": "0.3.*|0.4.*"
      , "guzzle/http": "~3.6"
      , "symfony/http-foundation": "~2.2"
      , "symfony/routing": "~2.2"
    }
}

What is wrong? Please give me a solution. Thanks in advance :)

like image 819
Hossein Mobasher Avatar asked Jul 07 '14 12:07

Hossein Mobasher


2 Answers

Ok, here we go...

You must have ZMQ and ZMQ binding installed previously in operation system. The following exemples is based on Debian Linux but it should work in other OS.

First: Installing 0MQ: Go to http://zeromq.org/area:download and choose a package according your OS, in my case I've choosed POSIX tarball Stable Release 4.0.4.

~$ tar -xvf zeromq-4.0.4.tar
~$ cd zeromq-4.0.4
~$ ./configure
~$ make
~$ sudo make install

Ok, we just have installed ZMQ now need install zmq php binding... Make sure you having php-dev and php pear installed. If no:

~$ sudo apt-get install php5-dev php-pear
~$ sudo pecl install zmq-beta

Ok, we have now ZMQ and php binding (ext-php) installed but we should add "extension=zmq.so" (Or extension=php_zmq.dll on windows) to php.ini: In my case:

~$ sudo nano /etc/php5/apache2/php.ini

NOTE: If PHP version is 5.4.x (or 5.4+, but I haven't tested yet...) you will need to add a zmq.ini file in /etc/php5/conf.d and put "extension=zmq.so":

~$ sudo nano /etc/php5/conf.d/20-zmq.ini

Reloadind HTTP server (in my case apache):

~$  sudo service apache2 reload

WOW!!! Now we gonna to update composer requirements:

~$ composer --verbose update
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing react/zmq (v0.3.0)
    Downloading: 100%         
    Extracting archive

Writing lock file
Generating autoload files
like image 114
felipsmartins Avatar answered Sep 19 '22 03:09

felipsmartins


If you are still getting the same error even after following the above answer then it might be because of incorrect php.ini used usually by composer.
You have to update the ini of CLI PHP also.

If you run the command php --ini from inside your terminal then you should see something like following:

enter image description here

This .ini meant for different usage than /etc/php5/apache2/php.ini. So, update that /etc/php5/cli/php.ini and add extension=zmq.so in it, if you think you already installed the extension following a correct workflow.

Hope you will get rid off that the requested PHP extension zmq is missing error while using composer installation.

like image 21
Nuhil Mehdy Avatar answered Sep 17 '22 03:09

Nuhil Mehdy