In this tutorial we're going to learn how to use and create your own Laravel facades. https://paulund.co.uk/how-to-create-a-facade-in-laravel#what-is-a-facadeA facade provides a static way of accessing the Laravel service container.

You can access the service container by using the app() or resolve() helper functions, passing in the alias for the class you want to return.

Facades make it easy to test and mock or fake the functionality because we can override the class returned from the service container.

The Laravel abstract facade class comes with a shouldReceive method that will allow you to make sure that the facade is called and how many times.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners