Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add route defaults support #689

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sudoanand
Copy link

@sudoanand sudoanand commented Oct 9, 2018

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant