The SitePoint PHP blog has a new tutorial posted showing you how to integrate Twig into a Laravel application with the help of the recently added "contracts" feature of the framework. Twig is a templating library that aims to be fast, secure and flexible for data output in multiple contexts.
Laravel 5 is finally out, and with all the awesome features it brings. One of the new architectural changes is the new Contracts Package. In this article we are going to understand the reasoning behind this change and try to build a practical use case using the new Contracts.
He starts with a brief look at what Contracts are and what it means to use them in a Laravel application. He then shows how to define the package installation (via Composer) to pull Twig in and register it with the application for future use. He creates a simple service provider to register Twig and return a new "TwigFactory" instance. This instance extends the "FactoryConnect" implementing the "ViewFactory" and, along with a custom "TwigView" object can be used just like you would normally output information via Blade.