Ratchet icon indicating copy to clipboard operation
Ratchet copied to clipboard

Add route defaults support

Open sudoanand opened this issue 7 years ago • 0 comments

Feature: Add support for default values in Symfony route configuration

With the current version of Ratchet, it is possible to make wildcard routes using route placeholders as mentioned in Symfony routing docs

I have written more about this here: How to implement wildcard routes in Ratchet WebSocket server

However, there is a catch. We can use routing placeholders but cannot make any of them optional, by passing a default value for them.

What this merge will add:

  • Add an optional 5th parameter to \Ratchet\App::route that is passed to \Symfony\Component\Routing\RouteCollection::add along with the _controller option.

For a setup like this: $server->route('/{something}/{anotherThing}', new MyApp(), array('*'))

After the merge, we can make anotherThing optional by modifying the route config to this:

$server->route('/{something}/{anotherThing}', new MyApp(), array('*'),null,array('anotherThing'=>1))

sudoanand avatar Oct 09 '18 07:10 sudoanand