arindam/blade-variable
Declare and use variables directly in Laravel Blade templates with a simple @var directive. Install via Composer (supports auto-discovery; provider available if needed) and set values like @var('name','Arindam') to access as $name in views.
No dependency on PHP version and LARAVEL version
composer require arindam/blade-variable
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
In providers section
Arindam\BladeVariable\BladeVariableServiceProvider::class,
//declare it
@var('myname', 'Arindam')
//use it
<h1>{{ $myname }}</h1>
//declare it
@var('myAge', 36)
//use it
<p>Age is : {{ $myAge }}</p>
The MIT License (MIT). Please see License File for more information.
If have any issue please write me.
How can I help you explore Laravel packages today?