Reputation:
i'm new to laravel Framework, i have a basic knowlege in php oop, in the web.php inside the routes folder this code
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
echo 'Hello!';
});
As far as i know that :: operator is used with static functions so i tried to find the find the static function "get" but i didn't found it.
Upvotes: 1
Views: 6034
Reputation: 87739
Because the Laravel architecture is a little bit more complex than just using static classes. This is what we call Facades.
When you call Route::get(), the Route class will try to get the instance of the real route object and then call the get() method.
The class is this one:
/vendor/laravel/framework/src/Illuminate/Routing/Router.php
And the method:
/**
* Register a new GET route with the router.
*
* @param string $uri
* @param \Closure|array|string|null $action
* @return \Illuminate\Routing\Route
*/
public function get($uri, $action = null)
{
return $this->addRoute(['GET', 'HEAD'], $uri, $action);
}
To better understand Facades, please read:
https://laravel.com/docs/5.3/facades
https://www.sitepoint.com/how-laravel-facades-work-and-how-to-use-them-elsewhere/
The ServiceContainer is a another big player in this process, read about it too:
https://laravel.com/docs/5.3/container
Upvotes: 7
Reputation: 180023
Route
is a facade to non-static functions. Here's the Route::get()
function: https://laravel.com/api/5.3/Illuminate/Routing/Router.html#method_get
Upvotes: 1