bengor-user/symfony-routing-bridge
Adapter bridge that integrates BenGorUser’s User library with Symfony Routing, enabling user-related routing compatibility. Install via Composer and run the fully PHPSpec-tested suite locally.
Routing component, enabling reuse of Symfony’s advanced routing features (e.g., route generators, matchers, or loaders) in a Laravel ecosystem. This is valuable if the team:
RouterInterface for third-party libraries expecting it (e.g., API Platform, Symfony UX).Illuminate/Routing) is mature and optimized. Introducing Symfony’s routing layer adds abstraction without clear benefits unless leveraging Symfony-specific features (e.g., dynamic route requirements, route enums, or advanced matching).Router to work with Laravel’s route definitions (likely via RouteCollection or Route objects).Route objects and vice versa.symfony/routing:^4.0|^5.0|^6.0), which may introduce version compatibility issues if Laravel’s ecosystem doesn’t align (e.g., Laravel 10 uses PHP 8.1+, Symfony 6.x).Route class, middleware handling, or service provider bootstrapping).php artisan route:cache) or route model binding?RouteServiceProvider extensions)?Symfony\Component\Routing\RouterInterface (e.g., API Platform, Symfony UX).composer require bengor-user/symfony-routing-bridge symfony/routing:^6.0
AppServiceProvider or a dedicated RoutingServiceProvider:
use BenGorUser\SymfonyRoutingBridge\SymfonyRouter;
public function register()
{
$this->app->singleton(SymfonyRouter::class, function ($app) {
$symfonyRouter = new SymfonyRouter();
$symfonyRouter->setRouteCollection($this->convertLaravelRoutesToSymfony());
return $symfonyRouter;
});
}
RouteCollection to Symfony’s RouteCollection (or vice versa). Example:
use Illuminate\Support\Facades\Route;
use Symfony\Component\Routing\Route as SymfonyRoute;
use Symfony\Component\Routing\RouteCollection;
private function convertLaravelRoutesToSymfony(): RouteCollection
{
$collection = new RouteCollection();
foreach (Route::getRoutes() as $route) {
$symfonyRoute = new SymfonyRoute(
$route->uri(),
$route->getMethods(),
$route->getAction()['uses'] ?? null
);
$collection->add($route->getName(), $symfonyRoute);
}
return $collection;
}
symfony/routing:^5.4) or fork the package.{user}) vs. Symfony’s route requirements (/user/{id<\d+>}) may need manual mapping.Illuminate/Routing source).How can I help you explore Laravel packages today?