Download the PHP package joserick/laravel-livewire-discover without Composer
On this page you can find all versions of the php package joserick/laravel-livewire-discover. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download joserick/laravel-livewire-discover
More information about joserick/laravel-livewire-discover
Files in joserick/laravel-livewire-discover
Package laravel-livewire-discover
Short Description Discover and autoload multiples components of livewire by convention (componentNamespace)
License GPL-3.0-or-later
Informations about the package laravel-livewire-discover
Laravel Livewire Discover
Notice: Migration to v1.0 || I need previous version (v0.3)
Automatically discover and load/register multiple/different class namespaces for Livewire components.
Installation
You can add the package via composer:
And then install the package with artisan:
Enjoying this package?
Config
Add to LivewireDiscoverServiceProvider.php
Or if you like, use "componentNamespace" function as in Blade Templates
Or use the config: 'config/livewire-discover.php'
Use
Call Livewire Components:
Or use form Routes:
"Obviously" you need to install the "layout" first for the Routes
Extra
Displays the list of loaded namespaces (prefix, aliases and paths)
If you want to check if all the namespaces are loading correctly you can run:
Which will show you a table with all the information:
Create your components quickly
You can create the files automatically using the following Artisan command. In the process it will ask you for the prefix to use.
If you prefer kebab-cased names, you can use them as well:
You may use namespace syntax or dot-notation to create your components in sub-directories. For example, the following commands will create a RegisterAdmin
component in the Auth
sub-directory:
Also if you don't want it to constantly ask you which prefix to select you can pass it directly with the --prefix
attribute
Manually configure the 'classpath' for component creation and listing
When automatically created components through the artisan livewire-discover:make
this obtains the directory path based on 'Composer Autoload File' If for some reason it is not possible to do this, you can manually configure the path, adding it as the third parameter:
Now when you create the component it will be created in the path you have specified.
Config 'view path' for component creation
Do you also want it to create the view
at a specific route? Just add the view route and it will automatically create it, simple as that:
Remember that these are examples, you can specify any path within your project and it will create it.
Migration to v1
Rename Config File
The configuration file name has changed from laravel-livewire-discover.php
to simply livewire-discover-php
Attributes Reversed
Replace Livewire::discover
for Livewire::componentNamespace
since the attributes in v1 are reversed but the componentNamespace
function maintains the structure of previous versions.
to
or in any case to maintain the use of the discover()
function you can invert the parameters.
Dot-Notation
Change in concatenation of prefixes with class name, previously it was concatenated using the "-" notation, now the dot-notation is used, so it must be changed in all calls to Livewire-Discover components
to
I need for v0.3.2
License
The GNU Public License (GPLv3). Please see License File for more information.