-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Examples don't match text, in routing chapter, section "Adding HTTP Method Requirements" #5583
Comments
That's a good catch @toddkaufmann. We changed the code examples in #5201, but apparently forgot to update the text too.Do you like to create a pull request for this? |
I can't update the text because I don't understand the intent. I scanned through the discussion on this issue, but not being versed enough in Symfony best practices I couldn't explain the use case & implementation properly. |
Hi everyone, I think it's essential for understanding this feature to have the exact same URL pattern for two different actions. The routing should only differ in the HTTP method, so you can clearly get the idea behind this. It was clear in the previous example using What do you think? |
Wouldn't this then become to lengthy and complicated? I bet beginners would sadly just stop reading when it comes to APIs here. Imo rewording the paragraph would be enough to show how you can use methods requirements. |
I understand your concerns, but is there a good use case for Adding HTTP Method Requirements for beginners then? I mean, does restricting |
I am actually not sure. Maybe this should simply be moved to the cookbook explained with the API example. |
I agree with bicpi an example of PUT would be nice |
Hi there, |
@Gwad Yes, you're right. The problem is, what do we consider as a simple, but valid use-case for this – which conforms to the Symfony Best Practices? API may is, but seems to complex to introduce in this context. Form processing is simple and clear, but does not follow the best practices. Any suggestions for another example? |
@bicpi Well, maybe that we should simply add a mention in the description text below the example code indicating that such non-exclusive routing is not suitable for REST APIs. If my memory serves me correctly, references to more complex Symfony2 notions were always done this way. On the other side, the examples codes were almost exclusively limited to the illustration of the current notion studied. Which is quite understandable, one's wouldn't illustrate some explanation with a digression... These examples codes are almost made to be copied and pasted by the reader :) |
I think that the API idea is very good. Nowadays almost everyone understands what an API is and how it works, so I don´t think it is going to put off users. In any case, some decission needs to be made. The current situation is showing some text which is plain wrong and has been like this for a very long time. We either fix the example or the text around it |
Fyi, as APIs are already introduced earlier in the book, I've created #6062 to rewrite this section to use a very basic API example. |
👍 |
This PR was merged into the 2.3 branch. Discussion ---------- Update HTTP method requirement example | Q | A | --- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.3+ | Fixed tickets | #5583 After many reports (#5779, #5659) of the text no longer matching the example, I think it's time to update the example. The example now uses an API, which is a very common thing now and often needs this feature. API's are already used in the Page Creation article, which is placed before this article, so it shouldn't be too hard to understand. I know that from a REST prespective, HEAD and GET using the same action doesn't seem that great, but it's the only action I could think of that may support 2 methods. Commits ------- 30c2750 Update method requirement example
or maybe I don't understand something.
The text says
"Despite the fact that these two routes have identical paths (/contact), the first route will match only GET requests and the second route will match only POST requests."
but the examples (annotations,yaml,xml,php) have "/news" and "/contact" and does not match the description.
Okay here in 2.2:
http://symfony.com/doc/2.2/book/routing.html#adding-http-method-requirements
It looks like something happened when annotations were added. I'm not familiar enough with the docs and where the example code block gets pulled in from.
The text was updated successfully, but these errors were encountered: