Reputation: 2184
For example - this function uses a facade:
File::get('path/to/file.txt');
It turns out the underlying class that actually supplies File::get
is Illuminate\Filesystem\Filesystem
I looked at the Laravel 4.2 documentation - thats the version Im using - and also the api reference but I couldn't find anything that would explain how to someone who didn't know in advance how to find the "real" class to a facade.
this tutorial on Laravel facades gives a method of doing it which involves
File
classFacade
Facade#__callstatic()
method__callstatic()
, resolveFacadeInstance()
when getFacadeAccessor()
returns string files
This is a good demonstration of whats going on, but I wouldn't want to do this regularly.
My question is, knowing that the "facaded classes" you use in your app dont necessarily have a the same name or some convention to help you search the filesystem, how can someone - who doesn't know in advance what the underlying class is - find the underlying class for a laravel facade?
Upvotes: 19
Views: 3921
Reputation: 5158
It seems that you can use getFacadeRoot()
. For example, to find out what's behind the Mail
facade:
get_class(Mail::getFacadeRoot());
// in my case returns 'Illuminate\Mail\Mailer'
Upvotes: 10
Reputation: 2556
This is a nice resource: https://laravel.com/docs/facades#facade-class-reference other than that make sure to install some kind of intellisense plugin for whatever editor you happen to be using. Most of them allow you to Ctrl+Right-Click on a class/method and go to the definition.
Upvotes: 11