From 24c1cd3c99170c8a92f86edada85a1d87225546e Mon Sep 17 00:00:00 2001 From: Jonathan Fontes Date: Wed, 14 Dec 2022 23:21:26 +0000 Subject: [PATCH] ADD: Console Application && Dump Versions --- {public => bootstrap}/bootstrap.php | 0 composer.json | 2 +- config/app.php | 15 ++++++++++++++- config/commands.php | 4 ++++ config/console.php | 9 +++++++++ config/providers.php | 2 ++ console | 13 +++++++++++++ public/index.php | 2 +- tests/CreateApplication.php | 2 +- tests/HelloWorldTest.php | 3 ++- 10 files changed, 47 insertions(+), 5 deletions(-) rename {public => bootstrap}/bootstrap.php (100%) create mode 100644 config/console.php create mode 100755 console diff --git a/public/bootstrap.php b/bootstrap/bootstrap.php similarity index 100% rename from public/bootstrap.php rename to bootstrap/bootstrap.php diff --git a/composer.json b/composer.json index 8005940..43e19c5 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "project", "require": { "php": "^8.1", - "gravatalonga/king-foundation": "^1.0", + "gravatalonga/king-foundation": ">=1.0.10", "middlewares/whoops": "^2.0", "doctrine/migrations": "^3.5" }, diff --git a/config/app.php b/config/app.php index 3b395e9..567aa2a 100644 --- a/config/app.php +++ b/config/app.php @@ -3,10 +3,23 @@ declare(strict_types=1); return [ - + /** + * Name of Application + */ 'name' => $_ENV['APP_NAME'] ?? 'APP', + /** + * Version of Application + */ + 'version' => $_ENV['VERSION'] ?? '1.0.0', + + /** + * Env of Application + */ 'env' => $_ENV['APP_ENV'] ?? 'local', + /** + * Enable Debug + */ 'debug' => $_ENV['APP_DEBUG'] ?? false, ]; diff --git a/config/commands.php b/config/commands.php index 1f6a841..fc663ac 100644 --- a/config/commands.php +++ b/config/commands.php @@ -3,4 +3,8 @@ declare(strict_types=1); return [ + /** + * Here is where command bus pattern ground base. + * You can provider Command::class => Handler::class pattern can be define. + */ ]; diff --git a/config/console.php b/config/console.php new file mode 100644 index 0000000..4a82207 --- /dev/null +++ b/config/console.php @@ -0,0 +1,9 @@ + AppDebugCommand::class + * **Note**: You need to bind AppDebugCommand::class also to container. + */ +]; \ No newline at end of file diff --git a/config/providers.php b/config/providers.php index e04bfcf..a777540 100644 --- a/config/providers.php +++ b/config/providers.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Gravatalonga\KingFoundation\CommandBusServiceProvider; +use Gravatalonga\KingFoundation\ConsoleServiceProvider; use Gravatalonga\KingFoundation\DatabaseServiceProvider; use Gravatalonga\KingFoundation\LogServiceProvider; use Gravatalonga\KingFoundation\SlimServiceProvider; @@ -17,5 +18,6 @@ new SlimServiceProvider(), new DatabaseServiceProvider(), new CommandBusServiceProvider(), + new ConsoleServiceProvider(), new TwigServiceProvider() ]; \ No newline at end of file diff --git a/console b/console new file mode 100755 index 0000000..36c7b03 --- /dev/null +++ b/console @@ -0,0 +1,13 @@ +#!/usr/bin/env php +run(); \ No newline at end of file diff --git a/public/index.php b/public/index.php index 8a5c8b9..6c9c81d 100644 --- a/public/index.php +++ b/public/index.php @@ -5,6 +5,6 @@ /** * @var \Gravatalonga\KingFoundation\Kernel $app */ -$app = require_once "bootstrap.php"; +$app = require_once "../bootstrap/bootstrap.php"; $app->run(); \ No newline at end of file diff --git a/tests/CreateApplication.php b/tests/CreateApplication.php index 9632dc3..c1646ad 100644 --- a/tests/CreateApplication.php +++ b/tests/CreateApplication.php @@ -8,6 +8,6 @@ trait CreateApplication { public function createApplication() { - $this->app = require_once __DIR__ . "/../public/bootstrap.php"; + $this->app = require_once __DIR__ . "/../bootstrap/bootstrap.php"; } } \ No newline at end of file diff --git a/tests/HelloWorldTest.php b/tests/HelloWorldTest.php index 4b715fb..adeb5b9 100644 --- a/tests/HelloWorldTest.php +++ b/tests/HelloWorldTest.php @@ -5,6 +5,7 @@ namespace Tests; use Gravatalonga\KingFoundation\Kernel; +use Gravatalonga\KingFoundation\Testing\InteractHttp; use Gravatalonga\KingFoundation\Testing\TraitRequest; use Slim\Psr7\Request; use Slim\Psr7\Response; @@ -14,7 +15,7 @@ */ class HelloWorldTest extends TestCase { - use TraitRequest; + use InteractHttp; public function setUp(): void {