Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable PHP redis extension on Travis

I'm running Travis CI for running my tests. I'm using the Trusty container with php v5.6.

Here is my entire .travis.yml file:

language: php

dist: trusty

php:
  - '5.4'

before_script:
  - phpenv config-rm xdebug.ini
  - before_script: echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

sudo: required

install:
  - npm install -g gulp
  - composer install

env:
  - APP_ENV=circleci

script:
  - gulp test

The before_script: syntax is copied directly from the travis documentation but my builds fail with a composer error saying:

- The requested PHP extension ext-redis * is missing from your system. Install or enable PHP's redis extension.
like image 477
emersonthis Avatar asked Jun 18 '16 00:06

emersonthis


People also ask

How connect PHP to Redis?

php //Connecting to Redis server on localhost $redis = new Redis(); $redis->connect('127.0. 0.1', 6379); echo "Connection to server sucessfully"; //set the data in redis string $redis->set("tutorial-name", "Redis tutorial"); // Get the stored data and print it echo "Stored string in redis:: " .

How do I install the PHP Redis extension?

If you want to use PHP-based applications with the Redis server, you should install the PHP Redis extension using the following command. Before installing the module, you should already install PHP in the system. Your system has a specific version of PHP. You should also need to install a distinct version of the PHP Redis extension.

What version of Redis do I need to install?

The most recent version of the Redis extension can only be installed on PHP 7.0 and above. If you need to use the Redis extension on PHP 5.4, 5.5, or 5.6, you mustrun Version 2.2.8. In the examples shown, replace "5.X" with your app's PHP version (for example, "5.4").

Why is the Redis extension not working in my site?

The extension is not loaded in this environment (fpm-fcgi). If it was installed, be sure to load the extension in your php.ini and to restart your PHP and web server processes. It would be great if someone can help to show how to redis extension in php.ini for the site by Wordops.

How to add Redis extension in MAMP?

Change the php version to yours. After successfully installing, will probably say something like this: configuration option "php_ini" is not set to php.ini location You should add "extension=redis.so" to php.ini So you need to go to your php.ini, and add extension=redis.so. For me, this folder is: /Applications/MAMP/bin/php/php7.3.9/conf/php.ini


1 Answers

It appears that this documentation is incorrect! Instead of before_script: it needs to be before_install:. This seems to work fine:

before_install:
  - phpenv config-rm xdebug.ini
  - before_script: echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
like image 105
emersonthis Avatar answered Oct 03 '22 20:10

emersonthis