François' Blog

Using libsodium-php in Travis-CI

Published on 2017-01-25

Update: switched to new PPA, from ppa:chris-lea/libsodium to ppa:ondrej/php that contains a newer libsodium that actually has \Sodium\compare.

For my OAuth 2.0 server I needed to be able to use libsodium in PHP, unfortunately the images on Travis-CI are still based on Ubuntu precise, or if you want trusty, but they do not contain libsodium-dev which would be needed to install the PECL module libsodium-php.

So, below you'll find my .travis.yml that installs both libsodium-dev from a PPA and builds the PECL module:

language: php
sudo: required
  - 5.4
  - 5.5
  - 5.6
  - 7.0
  - 7.1
  - sudo add-apt-repository ppa:ondrej/php -y
  - sudo apt-get update -q
  - sudo apt-get install libsodium-dev -y
  - pecl install libsodium
  - composer install

script: phpunit --coverage-text tests