Reputation: 1755
So I am examining the code of Laravel
I'm looking at the Storage facade. I think this is the way it's being loaded. Correct me if I am wrong.
When ever we access the
Storage::get('someFile.txt');
The Storage is being accessed through the alias in the config am I correct?
'Storage' => Illuminate\Support\Facades\Storage::class
It will then access the this function I believe
protected static function getFacadeAccessor(){
return 'filesystem';
}
protected function registerManager(){
$this->app->singleton('filesystem', function () {
return new FilesystemManager($this->app);
});
}
So overall The Facade is referencing the filesystem on the service container am I correct?
Upvotes: 2
Views: 71
Reputation: 19285
Yes, that is true: all the Facades in laravel are a only a convenient way to resolve objects from the Service Container and call methods on them
so, first you register a binding on the Service Container, and once you've done it, instead of doing
$fs = App::make('filesystem');
$file = $fs->get('someFile.txt');
you can simply do:
$file = Storage::get('someFile.txt');
Upvotes: 1