5 * Example commandline front controller
7 * The commandline tool is useful for providing ad-hoc access to our class implementations
10 // If we're running from phar load the phar autoload file.
11 $pharPath = \Phar::running(true);
13 $autoloaderPath = "$pharPath/vendor/autoload.php";
15 if (file_exists(__DIR__.'/vendor/autoload.php')) {
16 $autoloaderPath = __DIR__.'/vendor/autoload.php';
17 } elseif (file_exists(__DIR__.'/../../autoload.php')) {
18 $autoloaderPath = __DIR__ . '/../../autoload.php';
20 die("Could not find autoloader. Run 'composer install'.");
23 $classLoader = require $autoloaderPath;
25 // Customization variables
26 $argv = $_SERVER['argv'];
27 $appName = "SiteAlias";
28 $appVersion = trim(file_get_contents(__DIR__ . '/VERSION'));
29 $commandClasses = [ \Consolidation\SiteAlias\Cli\SiteAliasCommands::class ];
30 $selfUpdateRepository = 'consolidation/site-alias';
31 $configPrefix = 'SITEALIAS';
32 $configFilePath = getenv($configPrefix . '_CONFIG') ?: getenv('HOME') . '/.site-alias/site-alias.yml';
34 // Define our Runner, and pass it the command classes we provide.
35 $runner = new \Robo\Runner($commandClasses);
37 ->setSelfUpdateRepository($selfUpdateRepository)
38 ->setConfigurationFilename($configFilePath)
39 ->setEnvConfigPrefix($configPrefix)
40 ->setClassLoader($classLoader);
42 // Execute the command and return the result.
43 $output = new \Symfony\Component\Console\Output\ConsoleOutput();
44 $statusCode = $runner->execute($argv, $appName, $appVersion, $output);