Тёмный
No video :(

Using single action controllers in Laravel 

Andrew Schmelyun
Подписаться 36 тыс.
Просмотров 9 тыс.
50% 1

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 29   
@wayz9
@wayz9 Год назад
I am doing just this (what you said at the end) - heavy business logic into the action classes, everything else not that heavy goes to the regular controller. Few months later I came back to revisit a project and instantly got familiar with (the one using this approach). The application was medium size project for assets & packages with a unique feature of uploading csv to populate records. I have found that colleagues in my company like to go even on small apps with 3 different patterns mixed together and they would copy paste someone's mess and re use it over and over... So guys please think before you act, just ask yourself is this even gonna be used ever? Matt Stauffer had a great talk on Laracon 2022 about abstracting too early, highly recommended! Anyway excellent video Andrew, keep up the good work!
@SXsoft99
@SXsoft99 10 месяцев назад
abstracting too early comes, for some, with experience there are people 10 years+ that abstract it because they read something somewhere without understanding why and there are others that recognize certain things from the start of the project and extrat those
@JohnnyBigodes
@JohnnyBigodes Год назад
I usually only use invokable controllers on routes that will only have one single method. Yes it is a design choice, but I personally dont like it.
@stojankukrika7242
@stojankukrika7242 Год назад
totally agree :)
@33sprog5min2
@33sprog5min2 Год назад
To make it more readable you should name the method on the controller
@JohnnyBigodes
@JohnnyBigodes Год назад
@@33sprog5min2 Why should you do that if you are using an invokable method? Dont get the point...
@mikulcek
@mikulcek Год назад
So, if you don't like it, why keep using it?
@NathanBudd
@NathanBudd Год назад
I like the way you named your controllers here. I've recently started using Single Action Controllers, but I've been trying to use the RESTFUL naming convention, eg PostsIndexController, PostDeleteController etc, but yours is much more readable and clear as to what it does.
@Denakino
@Denakino Год назад
I have to disagree here, I think Posts/CreateNewPostsController has no valuable information over Posts/CreateController or even Posts/CreateNewController. Why namespace controllers if you repeat the namespace in the controller name? Sure, in the routes file, CreateNewPostsController::class looks nice, but so does Posts/CreateController::class
@haallefs
@haallefs 6 месяцев назад
Nice explanation! 🙂
@connorabbas6449
@connorabbas6449 Год назад
Big fan of your channel and Laracast contributions. Keep up the great work, Andrew. Also, what VS Code theme are you using?
@aschmelyun
@aschmelyun Год назад
Thanks! I'm using Ace Palenight now: marketplace.visualstudio.com/items?itemName=acestojanoski.ace-palenight
@0xAndie
@0xAndie Год назад
Good use for Action classes.
@kenamreemas3295
@kenamreemas3295 Год назад
hi, can you create a tutorial for implementing a microservice architecture with laravel?
@NoahNobody
@NoahNobody Год назад
I have recently started using htmx with laravel. I use these single action controllers to process the rerendering of some component, like a search results filter.
@rahulxcr
@rahulxcr Год назад
Thanks for the video. That's very helpful.
@SXsoft99
@SXsoft99 10 месяцев назад
single use controllers are nice as long as you don't want to have certain things shared, like a project specific way of logging data fro trasability purposes, queries, caching I personally prefer to: - move my validation to request classes - move my business logic either to a repository (either just quesries or multiple part execution)/action/service class - move common things like: http calls, data remaping, caching, etc to a lib/herper class - don't add the model to parameters in controllers and move the logic to somewhere i can query it (with eager loading or joins etc) with the ID as a parameter, mostly because in certain cases i want to add conditions directly in the sql query and early break the code execution if they aren't meet, instead of doing a query/multiple and check it in the code
18 дней назад
Can't you extend parent controller or use a trait?
@MedyZeus
@MedyZeus Год назад
Amazing video.. thanks 🙏🏻
@nihongo_
@nihongo_ Год назад
thank u👍
@aschmelyun
@aschmelyun Год назад
Of course, glad to help!
@bulent2435
@bulent2435 Год назад
I like better multiple methods in controllers and somewhere else all bussiness logic.
@ernestofavio6735
@ernestofavio6735 Год назад
Nice video but I dont find the advantage og this single actions.
@bowiemtl
@bowiemtl Год назад
I wish I saw this video 6 months ago haha
@lexxkrt
@lexxkrt Год назад
серьезно? в 2023 году об этом кто-то не знает еще? тема не раскрыта, зачем это нужно? это называется контроллер одного действия, зачем для CRUD использовать такой контроллер? думал что то новое покажите
@moimoi7973
@moimoi7973 Год назад
В этом нет ничего нового, но сейчас это немного модно
@iloginu
@iloginu Год назад
Так и не понял зачем это нужно.
@phojie6868
@phojie6868 Год назад
is this recommended if your app is only having APIS ?
@phojie6868
@phojie6868 Год назад
I would rather choose APIResource + Services/Actions architecture
Далее
Get started with Laravel events and listeners
15:37
Просмотров 19 тыс.
5 tips for supercharged Laravel Eloquent queries
16:29
Useful gadget for styling hair 💖🤩
00:20
Просмотров 1,4 млн
Can You Bend This Bar?
01:00
Просмотров 5 млн
Why do big Companies use Java, and NOT PHP?
12:34
Просмотров 222 тыс.
101 Weird But Useful Minecraft Hacks
48:36
Просмотров 4,4 млн
WOW! Laravel's pipeline pattern is AWESOME
20:39
Просмотров 13 тыс.
Faster Eloquent: Avoid Accessors with Foreach
9:35
Просмотров 53 тыс.
Become a PRO at Using Components in Laravel
32:51
Просмотров 37 тыс.
Useful gadget for styling hair 💖🤩
00:20
Просмотров 1,4 млн