Auto-register Livewire components outside base namespace
Livewire only supports having one root namespace for your components. This package allows you to automatically register components outside the base namespace.
You can install the package via composer:
composer require soyhuce/livewire-component-auto-registerYou can publish the config file with:
php artisan vendor:publish --tag="livewire-component-auto-register-config"In the config/livewire-component-auto-register.php file, you can specify the namespaces you want to register components from.
'paths' => [
'Support\\Livewire' => base_path('app/Support/Livewire'),
],From now, all components in the app/Support/Livewire namespace will be automatically registered and be usable in your views.
For example, if you have a component app/Support/Livewire/ProgressBar.php, you can use it in your views like this:
<livewire:progress-bar />
Component discovery can be cached using the livewire-component-auto-register:cache command.
php artisan livewire-component-auto-register:cacheCache can be cleared using the livewire-component-auto-register:clear command.
php artisan livewire-component-auto-register:clearCommands are registered as optimization command inside Laravel, meaning that php artisan optimize and php artisan optimize:clear will automatically run them.
Sometimes, your IDE may not be able to resolve the components correctly (particularly Laravel IDEA plugin). You can generate a helper file using the livewire-component-auto-register:ide-helper command.
php artisan livewire-component-auto-register:ide-helperYou can configure ide-helper file path in the configuration file.
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.