Skip to content

Commit 23dced4

Browse files
committed
fix: register the Client frontage when it is there, skip it when it is not
The previous commit stopped the fatal by deleting the reference. That half was right — Core\Front\Client\Boot was extracted to its own package and an application without it fataled during Application::configure(). But the other half was wrong, and worse. The client package declares no providers for Laravel's package discovery, only "dont-discover", so this aggregate is the ONLY thing that registers the Client frontage. Verified against a live application: Core\Front\Client\Boot resolves from vendor/dappcore/client, is REGISTERED at runtime, and gets there through this list and nothing else. Dropping the line trades a loud failure for a silent one — an application that boots cleanly and has quietly lost its customer dashboard. Registered conditionally instead, in both the provider list and middleware(), so it works installed and uninstalled. The regression test kept its "does not fatal without the package" case and gained the case that was missing: with the package present, the frontage is actually registered. That one skips where the package is absent, which is this repo, and is the half that would have caught the mistake. 448 pre-existing failures unchanged either side of this commit. Co-Authored-By: Virgil <virgil@lethean.io>
1 parent bb67878 commit 23dced4

2 files changed

Lines changed: 50 additions & 9 deletions

File tree

‎src/Core/Front/Boot.php‎

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,20 @@
3131
* Api - HTTP → JSON (REST API) — php-api
3232
* Mcp - HTTP → JSON-RPC (MCP protocol) — php-mcp
3333
*
34-
* Client\Boot lived here until it was extracted to the standalone
35-
* php-client package (see git history: "refactor: extract Service +
36-
* Client to standalone packages"). The extraction deleted
37-
* src/Core/Front/Client/ but left this class still hard-referencing
38-
* Client\Boot in both $providers and middleware() — a class that no
39-
* longer exists in this repo — which fataled Application::configure()
40-
* for every consuming app, not just ones missing php-client.
34+
* Client\Boot lived here until it was extracted to the standalone client
35+
* package. The extraction deleted src/Core/Front/Client/ but left this
36+
* class hard-referencing Client\Boot in both $providers and middleware(),
37+
* so an application without that package fataled during
38+
* Application::configure() on a class that is no longer here.
39+
*
40+
* It cannot simply be dropped either. The client package declares no
41+
* providers for Laravel's package discovery — only "dont-discover" — so
42+
* this list is the ONLY thing that registers the Client frontage.
43+
* Removing the line stops the fatal and silently takes the dashboard with
44+
* it, which is the worse failure of the two: an application that boots
45+
* fine and has quietly lost a surface.
46+
*
47+
* So it is registered when it is installed, and skipped when it is not.
4148
*/
4249
class Boot extends AggregateServiceProvider
4350
{
@@ -49,6 +56,15 @@ class Boot extends AggregateServiceProvider
4956
Components\Boot::class,
5057
];
5158

59+
public function register(): void
60+
{
61+
if (class_exists(Client\Boot::class)) {
62+
$this->providers[] = Client\Boot::class;
63+
}
64+
65+
parent::register();
66+
}
67+
5268
/**
5369
* Configure HTTP middleware - delegates to each HTTP frontage.
5470
* Stdio has no HTTP middleware (different transport).
@@ -58,6 +74,13 @@ public static function middleware(Middleware $middleware): void
5874
Web\Boot::middleware($middleware);
5975
Admin\Boot::middleware($middleware);
6076

77+
// Same reason as the provider list above: present when the client
78+
// package is installed, absent when it is not, and its middleware
79+
// group has to follow it either way.
80+
if (class_exists(Client\Boot::class)) {
81+
Client\Boot::middleware($middleware);
82+
}
83+
6184
// API and MCP groups — inlined because middleware() runs during
6285
// Application::configure(), before package providers load.
6386
// Packages add their own aliases during boot via lifecycle events.

‎tests/Feature/FrontBootMiddlewareTest.php‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,29 @@ public function test_front_boot_middleware_does_not_reference_the_deleted_client
3232
$this->assertTrue(true);
3333
}
3434

35-
public function test_front_boot_aggregate_providers_do_not_reference_the_deleted_client_frontage(): void
35+
public function test_front_boot_aggregate_providers_do_not_hard_reference_the_client_frontage(): void
3636
{
3737
$ref = new \ReflectionClass(Boot::class);
3838
$providers = $ref->getDefaultProperties()['providers'];
3939

40-
$this->assertNotContains('Core\Front\Client\Boot', $providers);
40+
$this->assertNotContains('Core\\Front\\Client\\Boot', $providers);
41+
}
42+
43+
public function test_front_boot_registers_the_client_frontage_when_the_package_is_installed(): void
44+
{
45+
// The other half, and the one that matters more. The client package
46+
// declares no providers for Laravel's package discovery, so this
47+
// aggregate is the ONLY thing that registers the Client frontage —
48+
// dropping the reference to stop the fatal would take the dashboard
49+
// with it silently, in every application that has the package.
50+
if (! class_exists(\Core\Front\Client\Boot::class)) {
51+
$this->markTestSkipped('client package not installed in this checkout');
52+
}
53+
54+
$boot = new Boot($this->app);
55+
$boot->register();
56+
57+
$ref = new \ReflectionProperty($boot, 'providers');
58+
$this->assertContains(\Core\Front\Client\Boot::class, $ref->getValue($boot));
4159
}
4260
}

0 commit comments

Comments
 (0)