Loading…

What is Facade in laravel and how it is used? Explain

In Laravel, Facades offer a static interface to classes available inside the application's service container. They serve as static proxies for underlying classes present in the service container, offering benefit of expressive syntax while maintaining more flexibility and testability than other available traditional static methods.

All the facades are defined in the namespace Illuminate\Support\Facades for easy accessibility and usability.

Example

                                        

use Illuminate\Support\Facades\Cache;

     Route::get('/cache', function () {

     return Cache::get('PutkeyNameHere');

});

Suggest An Answer

No suggestions avaliable!

Latest post from Laravel Interview Questions

Ask Question