Reputation: 43
What I mean is, how is it you can access the Validator facade without using the FQN in a controller?
Ie, why does validator::make work, not requiring illuminate\blah\facades\validator::make()
How is this accomplished from a PHP standpoint? FYI, I'm not interested in how to alias a class through Laravel's App class, but rather the mechanics of it. Is it done through a custom autoloading function...?
Upvotes: 4
Views: 1129
Reputation: 111829
To be precise it's implemented in:
\vendor\laravel\framework\src\Illuminate\Foundation\AliasLoader.php
file, using class_alias() function as @user3158900 mentioned:
public function load($alias)
{
if (isset($this->aliases[$alias]))
{
return class_alias($this->aliases[$alias], $alias);
}
}
Upvotes: 3
Reputation: 33058
I believe it is accomplished through the class_alias()
function.
http://php.net/manual/en/function.class-alias.php
Upvotes: 1