Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Laravel 5.x Cookbook

You're reading from   Laravel 5.x Cookbook A recipe-based book to help you efficiently create amazing PHP-based applications with Laravel 5.x

Arrow left icon
Product type Paperback
Published in Sep 2016
Publisher Packt
ISBN-13 9781786462084
Length 402 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Terry Matula Terry Matula
Author Profile Icon Terry Matula
Terry Matula
Alfred Nutile Alfred Nutile
Author Profile Icon Alfred Nutile
Alfred Nutile
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Setting Up and Installing Laravel FREE CHAPTER 2. Using Composer Packages 3. Routing 4. Building Views and Adding Style 5. Working with Data 6. Adding Angular to Your App 7. Authentication, Security, and Subscriptions 8. Testing and Debugging Your Application 9. Adding Advanced Features to Your App 10. Deploying Your App Index

Using the Facade pattern

Using the preceding work, let's take it one step further in how easy it is to use this Client in our code.

Getting ready

Install Guzzle and set up the provider just as we did previously, and you are ready for this next recipe.

How to do it...

  1. Make a folder called Facades in your app folder.
  2. Then add a file called APIClient.php and make it look like this:
    How to do it...
  3. Then scroll way down to the Façade section of this file, where we can register the Facade in our config/app.php file like this:
    How to do it...
  4. Now, let's see it working in a test by adding the method called seeing_our_facade_work to our test:
    How to do it...
  5. Now run the test:
    How to do it...

How it works...

So, the amount of work is all it takes to make your Provider just as easy to use as View, File, Storage, and all the other Facades that come from Laravel that make it easy and enjoyable to use.

Also, we can change the test to show it being just as easily swapped out. We will cover this in the testing chapter.

See also

  • Laracasts and another great video from...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image