1. Go to this page and download the library: Download miko/laravel-latte library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Latte\Essential\TranslatorExtension;
use Miko\LaravelLatte\Runtime\Translator;
public function boot(): void
{
$latte = $this->app->get(\Latte\Engine::class);
$latte->addExtension(new TranslatorExtension([Translator::class, 'translate']));
}
namespace App\View\Components;
use Illuminate\View\View;
use Miko\LaravelLatte\IComponent;
class Alert implements IComponent
{
private array $params = [];
/**
* Get some services from service container
*/
public function __construct(private SomeService $someService)
{
}
/**
* Get variables from template
*/
public function init(...$params): void
{
$this->params = $params;
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|string
{
return view('components.alert', $this->params);
}
}
html
$ php artisan vendor:publish --provider="Miko\LaravelLatte\ServiceProvider"
html
{$text|nl2br}
{$text|nl2br: true} <!-- xhtml: true -->
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.