0
votes

I am creating an open source project written in PHP and I'm starting to use Travis CI for testing on PHP versions 5.4, 5.5, 5.6 and HHVM.

The tests for 5.5, 5.6 and HHVM pass without any issues, but I get an error on PHP 5.4.

The error is listed here: https://travis-ci.org/CodeRichard/simple-config/jobs/58154496

I noticed it had something to do with the PHPUnit package which I use for local development and pulled in using Composer. This version requires symfony/yaml ~2.1|~3.0. After a bit of googling, I found out the pipe symbol is used as an OR symbol. This bit confuses me a little.

When I read ~2.1|~3.0 I assume it'll try to pull in one and if it fails, the other. I know symfony/yaml 3.* requires PHP 5.5.9, whereas 2.* requires 5.3.9.

What I don't understand is why it fails. Isn't it supposed to pull in symfony/yaml 2.* instead?

Right now, I'm requiring PHPUnit 4.6.* for development. The requirement for PHPUnit is PHP 5.3.3. However, Composer fails when trying Travis CI is trying to test for PHP 5.4. This makes absolutely no sense. If it would crash on PHP 5.4 and PHPUnit 4.6 requires symfony/yaml 3.0, shouldn't the requirement be 5.5?

I know I can just downgrade PHPUnit to 4.5, but I wish to remain up to date, so I'd rather not.

2

2 Answers

0
votes

That error message is simple: Composer cannot install a component that got recorded in the composer.lock file, but doesn't match the requirements of THIS PHP:

symfony/yaml 3.0.x-dev requires php >=5.5.9

This will not work with PHP 5.4.

Downgrading your development machine to 5.4 and run composer update again will fix it.

Running composer update instead of composer install in Travis CI will also fix it. If you decide to do this, you should also run Travis with composer update --prefer-lowest to test that your declared minimum versions are correctly working.

You should also try to avoid "minimum-stability":"dev", unless you are really sure that you need bleeding-edge packages. Currently you are using no other packages, so it's not necessary to deal with the issues of unstable dev versions.

0
votes

Remove composer.lock

This is what I have in my .travis.yml

# ...

before_script:
  - rm composer.lock
  - composer install --no-interaction --prefer-source

# ...

Issue: #2823