Search code examples
phpcomposer-phpphpredispredis

How to pass in options for composer?


I am trying to get this package https://github.com/nrk/predis-async and the instructions says to do: composer require predis/predis-async. I tried downloading the options phpiredis extension but when I run composer it says:

 Problem 1
   - predis/predis-async v0.2.3 require ext-phireids * -> the requested PHP extension phpiredis is missing from your system

Do I need to add an extension to the php ini file (if so how do I do this)?

If that doesnt work the owner the github says "pass in ['phpiredis' => false] in the array of client options" how do I pass in options with composer?


Solution

  • The extension phpiredis woudl need to be added to php.ini to be loaded into the PHP process if you wanted to use it.

    But - according to the predis-async composer file, that ext-phpiredis module is only a suggestion - so Composer doesn't require it. However, that's only the case for the latest version of the code - the last stable release, v0.2.3 explicitly requires it - which is what you are seeing.

    My suggestion it to use the latest version of the code, with

    # in the 'require' part of composer
    "predis/predis-async": "dev-master",
    

    You can also explicitly list a specific sha1-hash if you didn't want the code to potentially be able change from underneath you when updating or deploying.

    That latest code has moved the extension to a suggestion.

    The client options are in the 'Predis\Async\Client' constructor (called by your PHP code), an array as 2nd parameter after the address of the Redis server.