I’m working for the Adsmurai engineering team since January, that’s around 8 months and a half right now. In this time, we’ve advanced a lot in the direction of splitting a big code monolith into different and isolated services.
One tool that helped us a lot to achieve this goal was Docker. We started with Ubuntu-based images for our development environment, that was the case during my first seven months.
But then we wanted to use Docker in our production servers too for reasons that are not important here: this is not a devops post! And at that point, we realized that using Alpine Linux for our base images could help us to save disk space, among other minor benefits. So we jumped to Alpine-based images.
And here is where our story really starts. Our applications started to crash… because there were missing functions and interfaces.
Composer didn’t complain about missing extensions, but it was evident that something that we needed was not there. Our problem was that Alpine, in order to obtain very little systems, splits its packages whenever it makes sense, but that’s not the case with Ubuntu nor Debian, nor other popular Linux distros.
So, because many PHP extensions are pre-packaged in a single bundle for systems
like Debian, Ubuntu, RedHat, Centos… many developers forget to declare some
extensions as dependencies of their packages. Extensions that typically fall
into this category are: ext-ctype
,
ext-fileinfo
,
ext-session
,
ext-tokenizer
…
This problem can be found across the entire Packagist packages repository, even if we look into the subset of super-popular packages, like Symfony components.
To end this post: my advice is to read the PHP.net documentation when we’re using special purpose functions in order to know if they belong to an extension, and declare such extensions as dependencies on our composer.json files.
Best regards!