Reptile Reptile - 1 year ago 82
PHP Question

PHP - how precisely should I define version

I'm configuring Docker Compose file and I need to specify a PHP version. Lets assume I just define

. Can I be sure that PHP version 7.1 will not become incompatible?

Of the following choices, what is the best way to define the version, and why?

php 7
php 7.0
php 7.0.9

Answer Source

Lots of big software projects use Semantic Versioning. So for example, in the version number of X.Y.Z, the X is the "major" version, the Y is the "minor" version, and the Z is the "patch" version. Software following the semver specification increments:

MAJOR version when you make incompatible API changes,

MINOR version when you add functionality in a backwards-compatible manner, and

PATCH version when you make backwards-compatible bug fixes.

PHP however does not follow the semver specification!

Loads of big PHP projects use it, but the language itself does not. In the case of the PHP language itself, there can be (and are) breaking changes in the "minor" version number, not only the "major" version number. Usually, we're interested in bugfixes, and possibly other backwards-compatible changes. But we're almost definitely not interested in changes which will break our software and turn you into a firefighter.

I'm telling you about the semver specification, because for most projects out in the universe, you will want to declare your version to use the major version, and then accept newer minor and patch versions, like redis:3 for example (actually Redis is a kind of bad example, because it doesn't exactly use semver, but close). But here specifically with PHP, you need to be more specific since you're looking for non-breaking changes only.

Therefore, php:7.0-fpm is probably what you're looking for.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download