In laravel i am not able to understand what
When you use
Route::method() like that you're using what's called a "facade". The
Route class is the facade in this context.
If you take a look at
Illuminate\Support\Facades\Route you'll see that it provides a single static method called
getFacadeAccessor, which returns a string
router. It's this string that references an instance of the
Illuminate\Routing\Router class in the IoC container.
During it's setup Laravel creates an instance of this class and stores it with
router as kind of like a key.
So when you do
Route::get(...), under the hood Laravel is using the facade accessor to find an instance of the Router class that's already been created and calls the
get method on it. It uses dynamic programming to achieve this, have a look at the
Illuminate\Support\Facades\Facade class for details of what's going on there, in particular the
__callStatic method which is where it all starts.
Facadeclass it extends, so the
__callStaticmethod is run.
static::getFacadeRoot()which if you follow the logic, will get you an instance of
$instanceis the instance of the router, and
$argsis what you passed to
Route::get('route', 'Controller@method');you actually end up calling
get('route', 'Controller@method')on an instance of
Illuminate\Routing\Router. Notice, you're not actually calling a static method.