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

define('LARAVEL_START', microtime(true));

$languagesPath = __DIR__.'/../addons/Languages';
$configPath = __DIR__.'/../config';
if (! file_exists($languagesPath) || ! file_exists($configPath)) {
    // helpdesk#3021: exit if not within the helpdesk base path (e.g. staging in /tmp)
    echo "This command can only be called from within the help desk base directory.";
    exit(0);
}

/*
|--------------------------------------------------------------------------
| System Requirements
|--------------------------------------------------------------------------
|
| This is an attempt to gracefully handle cases where the server does not
| meet the requirements for a Laravel application. These are stand-alone
| classes that only require PHP 5.3 to run.
|
*/
require __DIR__.'/bootstrap/console/requirements.php';

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any of our classes manually. It's great to relax.
|
*/

require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/

$kernel = $app->make('Illuminate\Contracts\Console\Kernel');
$status = $kernel->handle(
    $input = new Symfony\Component\Console\Input\ArgvInput,
    new Manager\Log\LoggingOutputDecorator
);

/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/

$kernel->terminate($input, $status);

exit($status);
