Nello
Nello

Reputation: 1755

Clarification of Flow Structure of Laravel Facade

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.

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

Answers (1)

Moppo
Moppo

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

Related Questions