skip to content
TJ Miller

Verifying Laravel Version Compatibility

/ 3 min read

I’ve been working with Honeybadger to build a new set of PHP integrations. I would like to write more about that soon, however, I feel like I’ve stumbled across something that could be useful to others. I wanted to share it as soon as I could.

For the Laravel package, I was aiming for Laravel 5.5 and newer support as it is the latest LTS version. I feel like it makes sense to support down to LTS unless it becomes too complex to do so or you are leveraging features that just don’t exist in the older versions.

In hindsight, I don’t think that I actually ever tested it against a 5.5 install. I relied on the CI process to make those verifications for me. I use orchestra/testbench to aid in the testing workflow. I scaffolded the project with spatie/skeleton-php. The Travis configuration I was using seemed to work well but in hindsight, I think it really only works well if you are supporting a single version of Laravel.

language: php
- 7.1
- 7.2
- COMPOSER_FLAGS="--prefer-lowest"
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
- curl -L > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
- vendor/bin/phpunit
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT

As Laravel 5.7 is now out, I needed to add support to both the package’s composer configuration and verification in CI. Previously, I only needed to verify against 5.5 and 5.6 I thought that having --prefer-lowest in the matrix would add the coverage I needed. Now that I am supporting three versions I felt that I needed a more specific way of verifying compatibility with different versions of Laravel.

I poked around to see what some other packages were doing and this is what I ended up putting together.

- $HOME/.composer/cache
language: php
- php: 7.1
env: LARAVEL='5.5.*' TESTBENCH='3.5.*'
- php: 7.1
env: LARAVEL='5.6.*' TESTBENCH='3.6.*'
- php: 7.1
env: LARAVEL='5.7.*' TESTBENCH='3.7.*'
- php: 7.2
env: LARAVEL='5.5.* 'TESTBENCH='3.5.*'
- php: 7.2
env: LARAVEL='5.6.*' 'TESTBENCH='3.6.*'
- php: 7.2
env: COVERAGE=1 LARAVEL='5.7.*' 'TESTBENCH='3.7.*'
fast_finish: true
- composer config discard-changes true
- if [[ $COVERAGE = '1' ]]; then ./bin/codeclimate setup; fi
- travis_retry composer self-update
- travis_retry composer require "laravel/framework:${LARAVEL}" "orchestra/testbench:${TESTBENCH}" --no-interaction --no-update
- travis_retry composer install --prefer-dist --no-interaction --no-suggest
- vendor/bin/phpunit
- if [[ $COVERAGE = 1 ]]; then ./bin/codeclimate report $TRAVIS_TEST_RESULT; fi

Unexpectedly, this caught some issues with Laravel 5.5 support in the core honeybadger-io/honeybadger-php library.

After updating some version constraints in that package I was able to get everything dialed in. Additionally, I spun up a Laravel 5.5 application locally and tested it for sanity’s sake for both positive and negative test cases. This ensured that the CI process was correctly passing and most importantly, failing when expected.

Travis Screenshot

I feel pretty confident in this solution and set of verifications now.

Check out the Honeybadger libraries:


For more thoughts, links, project and personal updates.