heroku / heroku-buildpack-php

Heroku's buildpack for PHP applications.

Home Page:https://devcenter.heroku.com/categories/php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setting php platform version ignored

acepoblete opened this issue · comments

A PHP ~8.1 project of mine kept failing the build step because the PHP version was being set to 8.3.2 even when my composer.json was set to the correct version. After hours of playing around with different settings and config on Heroku, I was able to get the build to start working again only when I manually set the PHP platform version to ~8.1.0 in the composer.lock file.

here is an example repo

If you deploy the main branch to Heroku you'll get php 8.3.2 even though the composer.json is set to ~8.1. However, if you deploy the branch doctored-up-php the buildpack will select the right PHP version for the build.

Your version selector ~8.1 means ">=8.1 <9.0.0".

This exact example is described in the docs: https://getcomposer.org/doc/articles/versions.md#tilde-version-range-

The correct version selector for your desired behavior is ~8.1.0: https://semver.madewithlove.com/?package=php&constraint=~8.1.0