-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.6] Adds ability to generate single action controller #24843
[5.6] Adds ability to generate single action controller #24843
Conversation
The Would it make sense to extend it to allow the user to automatically create actions? Or perhaps a |
You might be better off calling it a Handler instead of a Controller. |
If we're going to add this at all I think I would prefer an option like |
@taylorotwell it's |
@hivokas @taylorotwell How to define named route for this situation? Please enlighten me. |
Route::post('/comment', 'StoreCommentController')->name('comment.store'); |
Why would you want to generate a single action controller vs a regular controller? |
Relevant: https://jenssegers.com/85/goodbye-controllers-hello-request-handlers I have been exclusively using Handlers only for a year now and I don't think I'll ever go back to Controllers. |
Read the article, great read. Love the concept. So the current command does here is not really making a controller per say, but making a handler. If Laravel was to implement this functionality why not classify these as their own group. In my opinion, this would be a great item to add to a 5.7 release (if there is time as I do not know the ETA on 5.7) or 5.8. In it's current state this PR sounds like it is trying to make a controller become something it isn't. I'd definitely use this if it was expanded upon, similar to the above mentioned idea, and placed into the framework as it's own group of responders. |
IMO single action controllers are very much a part of modern web development. No one is making a controller something it's not. It's simply a controller with a single action that handles one specific purpose instead of a controller with 7 actions and 7 different purposes. |
@gofish543 A single-action controller is still a controller. It’s still taking a request, working with domain models, and returning a response. |
@taylorotwell added information about |
@hivokas Nice idea :) |
This pull request adds ability to generate single action controller by specifying
--action
flag like this: