1

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.

MisterBla
  • 2,355
  • 1
  • 18
  • 29

2 Answers2

0

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.

Sven
  • 69,403
  • 10
  • 107
  • 109
  • My local php version is 5.5, you're saying that because I have that version, composer loads Symfony/yaml 3.0? Which gets recorded in my lock file and thus that's why it fails? – MisterBla Apr 12 '15 at 22:48
  • Also, it's best practice not to commit `composer.lock` to your open source library. On the other hand at has great meaning in application project. – Tomas Votruba Apr 13 '15 at 10:28
  • @Sven Thank you for that. @TomášVotruba Can you elaborate on not committing the `composer.lock` file? – MisterBla Apr 16 '15 at 14:25
  • @RichardA I pretty much agree with this: http://stackoverflow.com/a/24247443/1348344 – Tomas Votruba Apr 16 '15 at 17:42
  • 1
    @TomášVotruba I see! Thank you for the enlightenment! – MisterBla Apr 16 '15 at 17:50
0

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

bmatovu
  • 3,756
  • 1
  • 35
  • 37