Files
michaelschiemer/src/Framework/Router/RouteHelper.php
Michael Schiemer fc3d7e6357 feat(Production): Complete production deployment infrastructure
- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
2025-10-25 19:18:37 +02:00

142 lines
3.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Framework\Router;
use App\Framework\Attributes\Singleton;
/**
* Type-safe route helper for generating URLs with specific route enums
*/
#[Singleton]
final readonly class RouteHelper
{
public function __construct(
private UrlGenerator $urlGenerator
) {
}
/**
* Generate URL for web routes
*
* @param array<string, mixed> $params
*/
public function web(WebRoutes $route, array $params = [], bool $absolute = false): string
{
return $this->urlGenerator->route($route, $params, $absolute);
}
/**
* Generate URL for API routes
*
* @param array<string, mixed> $params
*/
public function api(ApiRoutes $route, array $params = [], bool $absolute = false): string
{
return $this->urlGenerator->route($route, $params, $absolute);
}
/**
* Generate URL for admin routes
*
* @param array<string, mixed> $params
*/
public function admin(AdminRoutes $route, array $params = [], bool $absolute = false): string
{
return $this->urlGenerator->route($route, $params, $absolute);
}
/**
* Generate URL for health routes
*
* @param array<string, mixed> $params
*/
public function health(HealthRoutes $route, array $params = [], bool $absolute = false): string
{
return $this->urlGenerator->route($route, $params, $absolute);
}
/**
* Generate URL for media routes
*
* @param array<string, mixed> $params
*/
public function media(MediaRoutes $route, array $params = [], bool $absolute = false): string
{
return $this->urlGenerator->route($route, $params, $absolute);
}
/**
* Generate URL for any route implementing RouteNameInterface
*
* @param array<string, mixed> $params
*/
public function any(RouteNameInterface $route, array $params = [], bool $absolute = false): string
{
return $this->urlGenerator->route($route, $params, $absolute);
}
/**
* Generate absolute URL for web routes
*
* @param array<string, mixed> $params
*/
public function absoluteWeb(WebRoutes $route, array $params = []): string
{
return $this->web($route, $params, true);
}
/**
* Generate absolute URL for API routes
*
* @param array<string, mixed> $params
*/
public function absoluteApi(ApiRoutes $route, array $params = []): string
{
return $this->api($route, $params, true);
}
/**
* Generate absolute URL for admin routes
*
* @param array<string, mixed> $params
*/
public function absoluteAdmin(AdminRoutes $route, array $params = []): string
{
return $this->admin($route, $params, true);
}
/**
* Check if current route matches given web route
*/
public function isCurrentWeb(WebRoutes $route): bool
{
return $this->urlGenerator->isCurrentRoute($route);
}
/**
* Check if current route matches given API route
*/
public function isCurrentApi(ApiRoutes $route): bool
{
return $this->urlGenerator->isCurrentRoute($route);
}
/**
* Check if current route matches given admin route
*/
public function isCurrentAdmin(AdminRoutes $route): bool
{
return $this->urlGenerator->isCurrentRoute($route);
}
/**
* Check if current route matches any route
*/
public function isCurrent(RouteNameInterface $route): bool
{
return $this->urlGenerator->isCurrentRoute($route);
}
}