ony/twigbridge

Adds the power of Twig to Laravel

dev-master 2020-05-30 12:37 UTC

This package is not auto-updated.

Last update: 2024-04-28 07:25:17 UTC


README

Require this package with Composer

composer require cfkarakulak/Twigra

Quick Start

Once Composer has installed or updated your packages you need to register Twigra with Laravel itself. Open up config/app.php and find the providers key, towards the end of the file, and add 'Twigra\ServiceProvider', to the end:

'providers' => [
    Twigra\ServiceProvider::class,
],

Now find the aliases key, again towards the end of the file, and add 'Twig' => 'Twigra\Facade\Twig', to have easier access to the Twigra (or Twig\Environment):

'aliases' => [
    'Twig' => Twigra\Facade\Twig::class,
],

Pass config (twigra.php to local config path)

At this point you can now begin using twig like you would any other view

//app/Http/routes.php
//twig template resources/views/hello.twig
Route::get('/', function () {
    return View::make('hello');
});

You can create the twig files in resources/views with the .twig file extension.

resources/views/hello.twig