Enabling Codeship PHP 5.6 Builds
The Problem
I recently had to fix a Codeship deployment pipeline to successfully build a PHP 5.6 project. This turned out to be quite tricky,
as no matter what I tried, PHP 8.2.10 was always installed and the build would fail. I tried many options to manage PHP versions, including phpenv, but I would get errors like
rbenv: version 5.6 is not installed
.
The Solution
After much effort, I was able to get the build to work by using the following commands in the Test Commands section of the Codeship project:
pip install awscli
composer self-update --1
composer --version
rm -rf /home/rof/.phpenv/
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php5.6 php5.6-xml php5.6-dev php5.6-curl php5.6-mbstring php5.6-bcmath libapache2-mod-php5.6 php5.6-mcrypt
export PATH="/usr/bin/php:/usr/bin/php5.6:$PATH"
sudo a2enmod php5.6
sudo systemctl restart apache2
composer global remove phpunit/phpunit
composer global require phpunit/phpunit:5.6
# This is just to verify that the correct version of PHP is installed
php -v
# The project in question uses a Makefile to deploy, so we run that here
make
Conclusion
It took a ton of research and help from Codeship support to get this working, and so I hope this helps someone else out there who is struggling with this issue.