Switching from console app class to full app class

Old: Illuminate\Console\Application
New: Illuminate\Foundation\Application
To allow for loading of service providers
This commit is contained in:
ilumos 2017-12-09 01:05:15 +00:00
parent b795f1dcde
commit 1a8ceb1ad5
2 changed files with 60 additions and 27 deletions

View file

@ -2,18 +2,9 @@
<?php <?php
use Dotenv\Dotenv; use Dotenv\Dotenv;
use Illuminate\Console\Application;
use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\ConsoleOutput;
use Zeropingheroes\LancacheAutofill\Commands\App\{
InitialiseDatabase, InitialiseDownloadsDirectory
};
use Zeropingheroes\LancacheAutofill\Commands\Steam\{
AuthoriseAccount, Dequeue, Initialise, QueueApp, QueuePopularApps, Requeue, SearchApps, ShowQueue, StartDownloading, UpdateAppList
};
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/vendor/autoload.php';
@ -22,8 +13,20 @@ $dotenv = new Dotenv(__DIR__);
$dotenv->load(); $dotenv->load();
$dotenv->required(['DOWNLOADS_DIRECTORY', 'STEAMCMD_PATH']); $dotenv->required(['DOWNLOADS_DIRECTORY', 'STEAMCMD_PATH']);
// Set up the console app // Create the application
$app = new Application(new Container, new Dispatcher, '5.5'); $app = new Illuminate\Foundation\Application(realpath(__DIR__));
// Register the console kernel
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
Zeropingheroes\LancacheAutofill\Console\Kernel::class
);
// Register the exception handler
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
Zeropingheroes\LancacheAutofill\Exceptions\Handler::class
);
// Set up the SQLite database connection // Set up the SQLite database connection
$capsule = new Capsule; $capsule = new Capsule;
@ -34,20 +37,13 @@ $capsule->addConnection([
$capsule->setAsGlobal(); $capsule->setAsGlobal();
$capsule->bootEloquent(); $capsule->bootEloquent();
// Make commands available // Run the console application
$app->add(new InitialiseDatabase); $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$app->add(new InitialiseDownloadsDirectory); $status = $kernel->handle(
$input = new ArgvInput,
new ConsoleOutput
);
$app->add(new Initialise); // Send output to the console once finished
$app->add(new UpdateAppList); $kernel->terminate($input, $status);
$app->add(new SearchApps); exit($status);
$app->add(new QueueApp);
$app->add(new QueuePopularApps);
$app->add(new ShowQueue);
$app->add(new StartDownloading);
$app->add(new AuthoriseAccount);
$app->add(new Dequeue);
$app->add(new Requeue);
// Run the console app
$app->run(new ArgvInput(), new ConsoleOutput());

37
src/Console/Kernel.php Normal file
View file

@ -0,0 +1,37 @@
<?php
namespace Zeropingheroes\LancacheAutofill\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Zeropingheroes\LancacheAutofill\Commands\Steam\{
AuthoriseAccount, Dequeue, Initialise, QueueApp, QueuePopularApps, QueueUsersApps, Requeue, SearchApps, ShowQueue, StartDownloading, UpdateAppList
};
use Zeropingheroes\LancacheAutofill\Commands\App\{
InitialiseDatabase, InitialiseDownloadsDirectory
};
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
InitialiseDatabase::class,
InitialiseDownloadsDirectory::class,
Initialise::class,
UpdateAppList::class,
SearchApps::class,
QueueApp::class,
QueuePopularApps::class,
QueueUsersApps::class,
ShowQueue::class,
StartDownloading::class,
AuthoriseAccount::class,
Dequeue::class,
Requeue::class,
];
}