skip to Main Content
 1. Route::get('list', [AppHttpControllersDriverDocumentController::class,'list']);
 2. Route::get('list', ['DriverDocumentController@list']);

What is the faster way to load callback from class in laravel route ?

I am writting REST API. I need high performance solution

2

Answers


  1. Both approaches are the same in performance. The Laravel documentation recommends defining your routes in an array format and using action verbs. (index instead of list)

    Route::get('/user', [UserController::class, 'index']);
    
    Login or Signup to reply.
  2. The answer is: it does not matter(*). You should cache things as part of your build script (php artisan config:cache, php artisan view:cache and php artisan route:cache).

    When you cache the routes, a file is created, in bootstrap/cache/routes-v7.php if I’m not mistaken. When the routes are cached, your routes/web.php and routes/api.php files will simply be ignored.


    (*) you should use the newer syntax still.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search