From e83598849ef0b106dc8b254d54b95cb741497ca3 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Thu, 2 May 2024 17:24:35 -0400 Subject: [PATCH 1/5] WIP --- .github/workflows/tests.yml | 2 - .../class-route-service-provider.php | 33 ---------------- bin/mantle | 9 +++-- bootstrap/app.php | 39 +++++++------------ bootstrap/providers.php | 10 +++++ composer.json | 8 +++- config/app.php | 34 ++++++++-------- mantle.php | 4 +- 8 files changed, 54 insertions(+), 85 deletions(-) delete mode 100644 app/providers/class-route-service-provider.php create mode 100644 bootstrap/providers.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0d2829b..6085c8b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,8 +7,6 @@ on: - '*.x' - '*.*.x' pull_request: - schedule: - - cron: '0 0 * * 0' jobs: php-tests: diff --git a/app/providers/class-route-service-provider.php b/app/providers/class-route-service-provider.php deleted file mode 100644 index 3de4682..0000000 --- a/app/providers/class-route-service-provider.php +++ /dev/null @@ -1,33 +0,0 @@ -allow_pass_through_requests(); - } - - /** - * Define routes for the application. - */ - public function map(): void { - Route::middleware( 'web' )->group( base_path( 'routes/web.php' ) ); - Route::middleware( 'rest-api' )->group( base_path( 'routes/rest-api.php' ) ); - } -} diff --git a/bin/mantle b/bin/mantle index d64576d..68f2f24 100755 --- a/bin/mantle +++ b/bin/mantle @@ -30,7 +30,7 @@ if ( file_exists( __DIR__ . '/../vendor/autoload.php' ) ) { | */ -$app = require_once MANTLE_BASE_DIR . '/bootstrap/app.php'; +$bootloader = require_once MANTLE_BASE_DIR . '/bootstrap/app.php'; /* |-------------------------------------------------------------------------- @@ -42,6 +42,7 @@ $app = require_once MANTLE_BASE_DIR . '/bootstrap/app.php'; | */ -bootloader( $app ) - ->set_base_path( MANTLE_BASE_DIR ) - ->boot(); +$bootloader->boot(); +// bootloader( $bootloader ) +// ->set_base_path( MANTLE_BASE_DIR ) +// ->boot(); diff --git a/bootstrap/app.php b/bootstrap/app.php index 1f856d2..5d7a3d9 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -5,30 +5,17 @@ * @package Mantle */ -use Mantle\Contracts; -use Mantle\Application\Application; +use Mantle\Framework\Bootloader; -/** - * Instantiate the application - */ -$app = new Application(); - -/** - * Register the main contracts that power the application. - */ -$app->singleton( - Contracts\Console\Kernel::class, - App\Console\Kernel::class, -); - -$app->singleton( - Contracts\Http\Kernel::class, - App\Http\Kernel::class, -); - -$app->singleton( - Contracts\Exceptions\Handler::class, - App\Exceptions\Handler::class -); - -return $app; +return Bootloader::instance() + ->with_base_path( dirname( __DIR__ ) ) + ->with_kernels( + console: App\Console\Kernel::class, + http: App\Http\Kernel::class, + ) + ->with_exception_handler( App\Exceptions\Handler::class ) + ->with_routing( + web: __DIR__ . '/../routes/web.php', + rest_api: __DIR__ . '/../routes/rest-api.php', + pass_through: true, + ); diff --git a/bootstrap/providers.php b/bootstrap/providers.php new file mode 100644 index 0000000..eccfb1c --- /dev/null +++ b/bootstrap/providers.php @@ -0,0 +1,10 @@ + [ - // Framework Providers. - Mantle\Filesystem\Filesystem_Service_Provider::class, - Mantle\Database\Factory_Service_Provider::class, - Mantle\Framework\Providers\Error_Service_Provider::class, - Mantle\Database\Model_Service_Provider::class, - Mantle\Queue\Queue_Service_Provider::class, - Mantle\Query_Monitor\Query_Monitor_Service_Provider::class, - Mantle\New_Relic\New_Relic_Service_Provider::class, - Mantle\Database\Pagination\Paginator_Service_Provider::class, - Mantle\Cache\Cache_Service_Provider::class, + // 'providers' => [ + // // Framework Providers. + // Mantle\Filesystem\Filesystem_Service_Provider::class, + // Mantle\Database\Factory_Service_Provider::class, + // Mantle\Framework\Providers\Error_Service_Provider::class, + // Mantle\Database\Model_Service_Provider::class, + // Mantle\Queue\Queue_Service_Provider::class, + // Mantle\Query_Monitor\Query_Monitor_Service_Provider::class, + // Mantle\New_Relic\New_Relic_Service_Provider::class, + // Mantle\Database\Pagination\Paginator_Service_Provider::class, + // Mantle\Cache\Cache_Service_Provider::class, - // Application Providers. - App\Providers\App_Service_Provider::class, - App\Providers\Asset_Service_Provider::class, - App\Providers\Event_Service_Provider::class, - App\Providers\Route_Service_Provider::class, - ], + // // Application Providers. + // App\Providers\App_Service_Provider::class, + // App\Providers\Asset_Service_Provider::class, + // App\Providers\Event_Service_Provider::class, + // App\Providers\Route_Service_Provider::class, + // ], /* |-------------------------------------------------------------------------- diff --git a/mantle.php b/mantle.php index 4f6ad61..b6199be 100644 --- a/mantle.php +++ b/mantle.php @@ -80,7 +80,7 @@ function () { | */ -$app = require_once __DIR__ . '/bootstrap/app.php'; +$bootloader = require_once __DIR__ . '/bootstrap/app.php'; /* |-------------------------------------------------------------------------- @@ -92,4 +92,4 @@ function () { | */ -bootloader( $app )->boot(); +$bootloader->boot(); From ee20905485c7cc652b1b5a742716c4757b1e3129 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Fri, 3 May 2024 15:49:54 -0400 Subject: [PATCH 2/5] Clear out the crud --- bin/mantle | 3 --- bootstrap/app.php | 1 - bootstrap/providers.php | 10 ---------- config/app.php | 24 ++++++------------------ 4 files changed, 6 insertions(+), 32 deletions(-) delete mode 100644 bootstrap/providers.php diff --git a/bin/mantle b/bin/mantle index 68f2f24..5e2af4a 100755 --- a/bin/mantle +++ b/bin/mantle @@ -43,6 +43,3 @@ $bootloader = require_once MANTLE_BASE_DIR . '/bootstrap/app.php'; */ $bootloader->boot(); -// bootloader( $bootloader ) -// ->set_base_path( MANTLE_BASE_DIR ) -// ->boot(); diff --git a/bootstrap/app.php b/bootstrap/app.php index 5d7a3d9..e4edd4f 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -8,7 +8,6 @@ use Mantle\Framework\Bootloader; return Bootloader::instance() - ->with_base_path( dirname( __DIR__ ) ) ->with_kernels( console: App\Console\Kernel::class, http: App\Http\Kernel::class, diff --git a/bootstrap/providers.php b/bootstrap/providers.php deleted file mode 100644 index eccfb1c..0000000 --- a/bootstrap/providers.php +++ /dev/null @@ -1,10 +0,0 @@ - [ - // // Framework Providers. - // Mantle\Filesystem\Filesystem_Service_Provider::class, - // Mantle\Database\Factory_Service_Provider::class, - // Mantle\Framework\Providers\Error_Service_Provider::class, - // Mantle\Database\Model_Service_Provider::class, - // Mantle\Queue\Queue_Service_Provider::class, - // Mantle\Query_Monitor\Query_Monitor_Service_Provider::class, - // Mantle\New_Relic\New_Relic_Service_Provider::class, - // Mantle\Database\Pagination\Paginator_Service_Provider::class, - // Mantle\Cache\Cache_Service_Provider::class, - - // // Application Providers. - // App\Providers\App_Service_Provider::class, - // App\Providers\Asset_Service_Provider::class, - // App\Providers\Event_Service_Provider::class, - // App\Providers\Route_Service_Provider::class, - // ], + 'providers' => [ + App\Providers\App_Service_Provider::class, + App\Providers\Asset_Service_Provider::class, + App\Providers\Event_Service_Provider::class, + ], /* |-------------------------------------------------------------------------- From 2630a45ba0ff7461902b0d591d9e43ee13014425 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Fri, 3 May 2024 16:15:09 -0400 Subject: [PATCH 3/5] Wiring up unit tests --- bootstrap/app.php | 2 +- composer.json | 1 + phpcs.xml | 1 + tests/CreateApplication.php | 12 +++--------- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index e4edd4f..61691ce 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -7,7 +7,7 @@ use Mantle\Framework\Bootloader; -return Bootloader::instance() +return Bootloader::create() ->with_kernels( console: App\Console\Kernel::class, http: App\Http\Kernel::class, diff --git a/composer.json b/composer.json index 35f3260..2585cd8 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "require-dev": { "alleyinteractive/alley-coding-standards": "^2.0", "phpstan/phpstan": "1.10.67", + "phpunit/phpunit": "^10.0.7", "szepeviktor/phpstan-wordpress": "^1.3" }, "minimum-stability": "dev", diff --git a/phpcs.xml b/phpcs.xml index e79c9e8..26b5f67 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -33,6 +33,7 @@ + views/ diff --git a/tests/CreateApplication.php b/tests/CreateApplication.php index e4f6de6..e6dac57 100644 --- a/tests/CreateApplication.php +++ b/tests/CreateApplication.php @@ -20,16 +20,10 @@ trait CreateApplication { * @return \Mantle\Application\Application */ public function create_application(): \Mantle\Contracts\Application { - // Allow non-mantle-site usage. - if ( ! file_exists( __DIR__ . '/../bootstrap/app.php' ) ) { - echo "Application bootstrap not found: creating new instance..."; - return new Application( __DIR__ . '/../', home_url( '/' ) ); - } + $bootloader = require __DIR__ . '/../bootstrap/app.php'; - $app = require __DIR__ . '/../bootstrap/app.php'; + $bootloader->make( Kernel::class )->bootstrap(); - $app->make( Kernel::class )->bootstrap(); - - return $app; + return $bootloader->get_application(); } } From 616044628e22dde9f20c44557075bca5bd119c92 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Fri, 7 Jun 2024 14:33:10 -0400 Subject: [PATCH 4/5] Fixing composer --- composer.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 2585cd8..91f39bd 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "alleyinteractive/composer-wordpress-autoloader": "^1.0", - "alleyinteractive/mantle-framework": "*", + "alleyinteractive/mantle-framework": "^1.1", "fakerphp/faker": "^1.23" }, "require-dev": { @@ -65,11 +65,5 @@ "@lint", "@phpunit" ] - }, - "repositories": { - "local": { - "type": "path", - "url": "../mantle-framework/" - } } } From fd1068a4f4fc8b7f6e44ed1c70608d6d4d2299d3 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 12 Jun 2024 21:58:50 -0400 Subject: [PATCH 5/5] Testing CI