Download the PHP package ambengers/kinetic without Composer
On this page you can find all versions of the php package ambengers/kinetic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ambengers/kinetic
More information about ambengers/kinetic
Files in ambengers/kinetic
Package kinetic
Short Description Adds view-composer like feature to Inertia.js Laravel adapter.
License MIT
Homepage https://github.com/ambengers/kinetic
Informations about the package kinetic
Kinetic
A package that adds view-composer like feature to Inertia.js Laravel adapter.
Use to be able to share props based on the Inertia component name.
Installation
Usage
This should be very intuitive if you are already familiar on how view composers work in Laravel.
Basic Registration
You can use Inertia::composer()
in any service provider to register composers for specific components.
The first argument accepts either a string or an array of Inertia components, and the second argument accepts either class string or a closure.
Wildcard Registration
You can also register composers to multiple components, or globally, using the wildcard *
syntax.
Class-based Composers
You can generate your composer class using this command:
Then you can call the $inertia->with()
method within the compose method to set the composed props, like so:
Closure-based Composers
If you opt for a closure-based composer, your closure must accept an instance of Inertia\ResponseFactory
class as the first argument.
Then you can call the with()
method from the factory class to set the composed props like so:
Multiple Composers
You can also set multiple composers to components using array, like so:
The array will be automatically merged with any existing composers for the components.
When you call the Inertia::render('User/Profile')
the props should now include the composed data.
Security
If you discover any security related issues, please send the author an email instead of using the issue tracker.
License
Please see the license file for more information.