Was wondering the same thing. What you said in your original post are my thoughts too. I have more questions than answers though
Dec 15, 2020
8
Level 1
Livewire Web App + REST API for Mobile?
Are there best practices around creating a Livewire based desktop/web app with separate REST API routes to support a mobile application without duplicate code? I had made a few assumptions and have a few concerns:
- Can Livewire components and API Controllers share request validation requirements? (Normally this would go in a Laravel Request class to be shared between web/api but this doesn't seem possible with Livewire. I haven't found a clean way to accomplish this)
- Share authorization logic easily as to not duplicate logic? (I'm assuming best practice is to write Policies and use that shared logic for both Livewire and API Controller)
- Share application logic? (Using a Repository pattern to move logic out of Controllers and Livewire Components to a central place)
I'd love to hear people's opinions surrounding the need for API routes in conjunction with a Livewire web app. Thank you!
Please or to participate in this conversation.