質問

I'm trying to find path location of Redirect class. Its facade return 'redirect' in getFacadeAccessor method.

<?php namespace Illuminate\Support\Facades;

class Redirect extends Facade {

/**
 * Get the registered name of the component.
 *
 * @return string
 */
protected static function getFacadeAccessor() { return 'redirect'; }

}

However I found that the real file responsible for this class definition is the 'Redirector.php'. I can't find any where that alias 'Redirect' to 'Redirector' class so I am wondering how Laravel know about Redirector class is actually the Redirect component of container?

役に立ちましたか?

解決

Have a look inside /vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php. It contains a class RoutingServiceProvider that has a method registerRedirector().

That's where a new Redirector instance is injected into $app['redirect']. This can then be accessed via the Redirect facade you mentioned in your question.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top