Skip to main content

Posts

Showing posts with the label facades in laravel

Facades in laravel

Facades provide static like interface to services inside the service container. we can access underlying implementation on these services (methods and properties). we can access every method in service classes without creating their instance(object). Mean it automatically resolve dependencies by creating instance of the service classes. How facades work ? 1) The service class contain only one method 'getFacadeAccessor()'. 2 ) This class also extend facades base class 3) So when we call method of this class without instance like cache::get('name) 4) It automatically call getFacadeAccessor() method create instance than find the method of the service class. How do I create a facade class and use in my application ? Since laravel largely uses facades rather every non static function has its equivalent facade available in service container, we must also follow the same way in our custom application. All of Laravel’s facades are defined in the Illuminate\Support\Facades namespace...