withProviders(static::$providers) ->withMiddleware(function (Middleware $middleware): void { // Session middleware priority $middleware->priority([ StartSession::class, ]); $middleware->redirectGuestsTo('/login'); $middleware->redirectUsersTo('/hub'); // Front module configures middleware groups (web, admin, api, mcp) Front\Boot::middleware($middleware); }) ->withExceptions(function (Exceptions $exceptions): void { // Clean exception handling for open-source // Apps can add Sentry, custom error pages, etc. })->create(); } /** * Get the application base path. * * Works whether Core is in vendor/ or packages/ (monorepo). */ protected static function basePath(): string { // Check for monorepo structure (packages/core-php/src/Core/Boot.php) // The monorepo root has app/ directory while the package root doesn't $monorepoBase = dirname(__DIR__, 4); if (file_exists($monorepoBase.'/composer.json') && is_dir($monorepoBase.'/app')) { return $monorepoBase; } // Standard vendor structure (vendor/*/core/src/Core/Boot.php) return dirname(__DIR__, 5); } }