Download the PHP package axn/laravel-view-components without Composer
On this page you can find all versions of the php package axn/laravel-view-components. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download axn/laravel-view-components
More information about axn/laravel-view-components
Files in axn/laravel-view-components
Package laravel-view-components
Short Description Provide a simple but effective view components system to Laravel.
License MIT
Homepage https://github.com/AXN-Informatique/laravel-view-components
Informations about the package laravel-view-components
Laravel View Components
Provide a simple but effective view components system to Laravel, similar to view composers but in a different way : while a composer is called when the view is rendered, with view component, the view is rendered by the component itself. So, the logic is more tied to the view.
- Installation
- Usage
Installation
With Composer:
In Laravel 5.5 the service provider is automatically included.
In older versions of the framework, simply add this service provider to the array
of providers in config/app.php
:
Usage
Create a class that extends Axn\ViewComponents\ViewComponent
and write the logic
of your component in the compose()
method. The compose()
method must return
the view contents.
Example:
Then use the @render
directive to render the component in a view:
Or the render()
helper to render the component elsewhere than in a view:
If you need to pass data to the component:
And in the component: