#!/usr/bin/env php
<?php

$iniDir = realpath(implode(DIRECTORY_SEPARATOR, [
    getcwd(),
    'vendor',
    'oicana',
    'installer',
    'php',
]));

if ($iniDir === false) {
    echo 'The Oicana extension is not installed. Run "composer install" and check its output for errors.' . PHP_EOL;
    echo 'To install the extension manually, see https://github.com/oicana/oicana/tree/main/integrations/php/oicana-php-installer#if-automatic-installation-fails' . PHP_EOL;
    exit(1);
}

echo PHP_EOL;
echo 'Run the following to enable the Oicana extension in this shell session:' . PHP_EOL;
echo PHP_EOL;

if (PHP_OS_FAMILY === 'Windows') {
    $current = getenv('PHP_INI_SCAN_DIR') ?: '';
    echo '  set "PHP_INI_SCAN_DIR=' . $current . ';' . $iniDir . '"' . PHP_EOL;
} else {
    echo '  export PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR:-}:' . $iniDir . '"' . PHP_EOL;
}

echo PHP_EOL;
echo 'Or add it to your shell profile to enable it permanently.' . PHP_EOL;
