artisan.php 1.36 KB
Newer Older
Taylor Otwell committed
1
<?php namespace Laravel\CLI; defined('DS') or die('No direct script access.');
2 3

use Laravel\Bundle;
4
use Laravel\Config;
Taylor Otwell committed
5
use Laravel\Request;
6 7 8 9 10 11 12 13 14

/**
 * Fire up the default bundle. This will ensure any dependencies that
 * need to be registered in the IoC container are registered and that
 * the auto-loader mappings are registered.
 */
Bundle::start(DEFAULT_BUNDLE);

/**
15 16 17 18
 * The default database connection may be set by specifying a value
 * for the "database" CLI option. This allows migrations to be run
 * conveniently for a test or staging database.
 */
Taylor Otwell committed
19 20

if ( ! is_null($database = get_cli_option('db')))
21
{
Taylor Otwell committed
22
	Config::set('database.default', $database);
23 24 25
}

/**
26 27 28 29 30
 * We will register all of the Laravel provided tasks inside the IoC
 * container so they can be resolved by the task class. This allows
 * us to seamlessly add tasks to the CLI so that the Task class
 * doesn't have to worry about how to resolve core tasks.
 */
Taylor Otwell committed
31
require path('sys').'cli/dependencies'.EXT;
32 33 34 35 36

/**
 * We will wrap the command execution in a try / catch block and
 * simply write out any exception messages we receive to the CLI
 * for the developer. Note that this only writes out messages
Chris Berthe committed
37
 * for the CLI exceptions. All others will not be caught
38 39 40 41
 * and will be totally dumped out to the CLI.
 */
try
{
42
	Command::run(array_slice($arguments, 1));
43 44 45 46 47 48 49
}
catch (\Exception $e)
{
	echo $e->getMessage();
}

echo PHP_EOL;