Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Utilize Laravel's Container for Dependency Resolution in LivewireServ…
…iceProvider Livewire Reference: livewire#7076 Jetstream Reference: laravel/jetstream#1390 The required update in `laravel/jetstream` has been merged into core, and tagged in [v4.0.4](https://github.com/laravel/jetstream/releases/tag/v4.0.4) ----- This pull request updates the LivewireServiceProvider class to utilize Laravel's container for resolving dependencies and instantiating objects, improving modularity and flexibility for app developers. With this change, developers can easily override core Livewire functionalities in their service providers as needed, such as Mechanisms and Features. These changes have been made with the aim of maintaining backward compatibility and ensuring that there are no side effects or incompatibilities. ----- Code snippet of the improvement and reasons why it's useful: ```php namespace App; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { public function register() { $this->app->singleton(\Livewire\Mechanisms\HandleRequests\HandleRequests::class, \App\HandleRequests::class); } } ``` Example of a `HandleRequests` Mechanism override, changing the mechanism boot logic. This is just an example, but there's many other use cases. ```php namespace App; use Livewire\Mechanisms\HandleRequests\HandleRequests as BaseHandleRequests; class HandleRequests extends BaseHandleRequests { function boot() { // ... } } ``` Thanks for your consideration! 🙌
- Loading branch information