Home > Blockchain >  Laravel Route Action
Laravel Route Action

Time:05-30

Between the two ways of writing route action, which is the fastest and most efficient?

Route::get('halo', [Api\V1\Client\HomeController::class, 'index']);

or

Route::get('halo', "App\Http\Controllers\Api\V1\Client\HomeController@index");

In this case, I have almost 500 routers, does the writing method of the two routers affect? Thanks in advance.

CodePudding user response:

This route: Route::get('halo', [Api\V1\Client\HomeController::class, 'index']); is Laravel 8 upwards version and the other is Laravel < 8.n. So the question would be which Laravel version you will use.

To the performance issue. Laravel cache the routes. It means it doesnt matter which style you will use.

Maybe must be the question which laravel version is faster.

CodePudding user response:

How you write a route has no effect on how fast the code will run. Whichever way you write, the basic function of the code remains the same.

  • Related