#!/bin/bash

# ---------------------------------------------------------------------------------
# Golang install recipe
# Fetches the latest stable Go release, installs to /usr/local/go,
# then installs go-based CLI tools.
# ---------------------------------------------------------------------------------

set -e

# install the Debian 13 php version
sudo apt install php-cli php-mysql php-curl php-mbstring php-zip

reload

# install/download composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'c8b085408188070d5f52bcfe4ecfbee5f727afa458b2573b8eaaf77b3419b0bf2768dc67c86944da1544f06fa544fd47') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
php composer-setup.php
php -r "unlink('composer-setup.php');"

# Move composer bin
sudo mv composer.phar /usr/local/bin/composer

echo ""
echo "✅ PHP setup complete."
