How to get underlying class name from Facade name in Laravel -
i finding bit difficult understand facades. particularly how find underlying class name/location facade name. have gone through documentation still not clear. example, when using auth::login() , found there no login() method in auth facade.
class auth extends facade { /** * registered name of component. * * @return string */ protected static function getfacadeaccessor() { return 'auth'; } /** * register typical authentication routes application. * * @return void */ public static function routes() { static::$app->make('router')->auth(); } } the auth facades getfacadeaccessor() method returns string auth. auth class should looking at? how resolve actual class?
thanks,
somewhere in serviceprovider auth key registered something. auth key that's in vendor/laravel/frameworksrc/illuminate/auth/authserviceprovider.php. can see in registerauthenticator() method, auth key registered illuminate\auth\authmanager singleton pattern.
the container has several ways bind key specific class. methods bind , singleton example. facades class call main class statically root namespace.
if want check out class used, can use following code: get_class(resolve('auth')). ofcourse, can replace auth string want check.
bonus: think can override behaviour registering own manager in kind of way. advise extend normal authmanager , overwrite methods want see changed.
Comments
Post a Comment