03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

File-Based CMS 307<br />

1 composer update<br />

Rendering Templates<br />

We’ve often used View::make() to render views. It’s great for when we have pre-defined view files<br />

and we want Laravel to manage how they are rendered and stored. In this tutorial, we’re going<br />

to be rendering templates from strings. We’ll need to encapsulate some of how Laravel rendered<br />

templates, but it’ll also give us a good base for extending upon the Blade template syntax.<br />

Let’s get started by creating a service provider:<br />

1 php artisan workbench formativ/cms<br />

This will generate the usual scaffolding for a new package. We need to add it in a few places, to be<br />

able to use it in our application:<br />

1 "providers" => [<br />

2 "Formativ\Cms\CmsServiceProvider",<br />

3 // …remaining service providers<br />

4 ],<br />

.<br />

This was extracted from app/config/app.php.<br />

1 "autoload" : {<br />

2 "classmap" : [<br />

3 // …<br />

4 ],<br />

5 "psr-0" : {<br />

6 "Formativ\\Cms" : "workbench/formativ/cms/src/"<br />

7 }<br />

8 }<br />

.<br />

This was extracted from composer.json.<br />

Then we need to rebuild the composer autoloader:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!