#!/bin/bash

# Update package index
apt-get update -y

# Install dependencies for PHP 8 and composer
apt install software-properties-common ca-certificates lsb-release apt-transport-https
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
apt update -y
# Install PHP 8
apt install php8 libapache2-mod-php8.0
systemctl restart apache2

# Install composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer
#Run composer update
cd /builds/Hassansam/centos7
composer update

# Run PHPUnit tests
vendor/bin/phpunit

# Verify installation
php -v
composer -v
