Laravel App Using Only Livewire Full-Page Components?
I’m planning a Laravel project using only Livewire full-page components, with service classes the logic and form requests for validation.
Does this even make sense, and what software architecture would this be considered?
thank you
Yes it makes sense, I have done this on a personal project.
And it works fine.
But you need to adapt the form requests so that it can be used with Livewire.
@vincent15000 would the project architecture still be considered MVC or something else?
@livewirestarter With Livewire, you still have models, views and controllers, so yes it will be considered an MVC architecture.
However like with Laravel, it's not a pure academic MVC architecture.
@vincent15000 fair, but just with the components in place of the controllers, right?
but i guess this is not the Best practice implementation of livewire...
thx for your anwsers
@livewirestarter Why do you say this ?
but i guess this is not the Best practice implementation of livewire
What is not the best pratice implementation of Livewire ?
Hmmm ... The components don't replace the controllers.
Some components can be called directly from the router and in this case the component controller replaces the standard Laravel controller.
Some other components are called from another component and not from a route.
@vincent15000
well i'm new to livewire but now that i really think about it... you can call it best practice for sure
i should've clarified. i meant that controllers are replaced by components but of course not all components are there to replace controllers
or what would controllers still be used for?
@livewirestarter In Livewire, controllers have 2 roles :
-
manage the component state and behavior, often contains some business logic which should better be exported to some other class like a service
-
be called from a route if it's a full page component (here an equivalent of the standard Laravel controllers)
All projects we build follow these patterns, which makes the navigation experience feel super spa (so to speak)
Please or to participate in this conversation.