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.

Controller Testing 355<br />

38 }<br />

.<br />

This file should be saved as app/Formativ/PostServiceProvider.php.<br />

.<br />

You will also need to load the Formativ namespace through the composer.json file. You can<br />

do that by using either PSR specification, or even through a classmap. More info on that at:<br />

https://getcomposer.org/doc/01-basic-usage.md#autoloading.<br />

https://getcomposer.org/doc/01-basic-usage.md#autoloading<br />

.<br />

You can find out more about making service providers at: http://laravel.com/docs/packages.<br />

http://laravel.com/docs/packages<br />

This does a couple of important things:<br />

1. Interfaces are connected to concrete implementations, so that we can type-hint the interfaces<br />

in our controller, and they will be resolved automatically, with the Laravel IoC container.<br />

2. We specify which interfaces are provided (in the provides() method) so that we can defer the<br />

loading of this service provider until the concrete implementations are called.<br />

We need to define the interfaces and concrete implementations:<br />

1

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

Saved successfully!

Ooh no, something went wrong!