1. Go to this page and download the library: Download dinhquochan/laravel-twig 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/ */
dinhquochan / laravel-twig example snippets
\DinhQuocHan\Twig\TwigServiceProvider::class,
'Twig' => \DinhQuocHan\Twig\Facades\Twig::class,
// Normal (template.html.twig or template.css.twig or template.twig)
return view('template', ['some_variable' => 'some_values']);
// With vender namespace
return view('vendor_namespace::template', $data);
class AppServiceProvider extends ServiceProvider
{
//
public function boot()
{
Twig::addFilter(new TwigFilter('money_format', function ($price) {
return sprintf('%d %s', number_format($price), 'US$');
}));
}
}