Lets look at how Facades work in Laravel 4 by investigating the flow of one of the facaded classes: URL. As in <?=URL::route('news')?>
.
As you'll see in the summary, this isn't exactly described in the procedural order your app is executed. But I think it serves to explain what's going on.
-
The app config has an aliases
array. In there is: 'URL' => 'Illuminate\Support\Facades\URL'
. If you look up that class, you'll see it just has this: protected static function getFacadeAccessor() { return 'url'; }
and that it inherits from Illuminate\Support\Facades\Facade
. We'll get back to this later.
-
Lets now turn to how the app boots up. The /vendor/laravel/framework/src/Illuminate/Foundation/start.php bootstrap file calls registerAliasLoader()
on an instance of Illuminate\Foundation\Application
.