#!/bin/bash

# PHP'yi bul
PHP_PATH=""

# Homebrew PHP
if [ -f "/usr/local/bin/php" ]; then
    PHP_PATH="/usr/local/bin/php"
# MAMP PHP
elif [ -d "/Applications/MAMP/bin/php" ]; then
    PHP_VERSION=$(ls -t /Applications/MAMP/bin/php/ | head -1)
    PHP_PATH="/Applications/MAMP/bin/php/$PHP_VERSION/bin/php"
# XAMPP PHP
elif [ -f "/Applications/XAMPP/xamppfiles/bin/php" ]; then
    PHP_PATH="/Applications/XAMPP/xamppfiles/bin/php"
# Sistem PHP
elif [ -f "/usr/bin/php" ]; then
    PHP_PATH="/usr/bin/php"
fi

if [ -z "$PHP_PATH" ] || [ ! -f "$PHP_PATH" ]; then
    echo "PHP bulunamadı!"
    exit 1
fi

echo "Using PHP: $PHP_PATH"
$PHP_PATH artisan migrate --force
