Mondata
Mondata

Reputation: 3

My Laravel application is too slow

I have a laravel application called jobclass, installed in my localhost, it's too slow for me (response time is too slow) and i dont know how to fix this problem, i checked routing file, and i guess maybe my problem is in that file, could someone help me :(

Sorry for english

Route::group([
'prefix'        => LaravelLocalization::setLocale(),
'middleware'    => ['local'],
'namespace'     => 'App\Http\Controllers'
], function ($router)
{
Route::group(['middleware' => ['web', 'installChecker']], function ($router)
{

// ADS
$router->pattern('id', '[0-9]+');
Route::get(LaravelLocalization::transRoute('routes.create'), 'Ad\PostController@getForm');
Route::post('create/submit', 'Ad\PostController@postForm');
Route::get('create/success', 'Ad\PostController@success');
Route::get('create/success-payment', 'Ad\PostController@getSuccessPayment');
Route::get('create/cancel-payment', 'Ad\PostController@cancelPayment');
Route::get('create/activation/{token}', 'Ad\PostController@activation');
Route::group(['middleware' => 'auth'], function ($router) {
$router->pattern('id', '[0-9]+');
Route::get('update/{id}', ['as' => 'adUpdateHelper', 'uses' => 'Ad\UpdateController@getForm']);
Route::post('update/{id}', ['as' => 'adUpdateSubmitHelper', 'uses' => 'Ad\UpdateController@postForm']);
Route::get('update/{id}/success', ['as' => 'adUpdateSuccessHelper', 'uses' => 'Ad\UpdateController@success']);
});
Route::get('{title}/{id}.html', ['as' => 'adHelper', 'uses' => 'Ad\DetailsController@index']);
Route::post('{id}/contact', ['as' => 'adContactHelper', 'uses' => 'Ad\DetailsController@sendMessage']);
Route::post('{id}/report', ['as' => 'adReportHelper', 'uses' => 'Ad\DetailsController@sendReport']);
Route::post('send-by-email', ['as' => 'adSendByEmailHelper', 'uses' => 'SearchController@sendByEmail']);
});
});

Upvotes: 0

Views: 10747

Answers (3)

Dananjaya
Dananjaya

Reputation: 669

I came here to get an answer for the problem I got last week when I'm using laravel 10.x. I'm posting my finding as it'll help for someone else.

I have a laravel api project which is located in my C: drive. But I'm using linux subsystem (WSL) to serve it and using symlink created under www folder.

But, it was too slow to serve. In WSL forums I saw there is slowness in handling files between NTFS and WSL file system. So, finally I remove the symlink and copy the project into WSL www folder and thereafter it servers really fast. As I'm using vscode, no problem with develpment as I can use WSL extention.

Upvotes: 0

João Mantovani
João Mantovani

Reputation: 2398

If you are on the localhost and the load are slow, there are somethings you may check to try to resolve the problem:

Check CDN

If you are on a localhost using CDN and your connection are slow, the css/js may slow your site load, try to use local files instead of CDN

Check the console errors (Chrome)

  • Press F12
  • Go to the console
  • Press F5

If some elements are not loading correctly, this may slow you site load. Check if any red erros appears and try to correct then.

Debug with F12 (Chrome)

  • Press F12
  • Go to network
  • Press F5

This process will debug your site load and you can see what's slowing (put your results here)

Audit the site (Chrome)

  • Press F12
  • Go to audtis
  • Select "Web page perfomance"
  • Select Reload Page and audit on load
  • Click on run

May you see anything that is affecting your performance you see anything that is afecting your perfomance.

You didn't provide some information for us, try to run these tests and put your results here.

[Edit]

All your page are loading slowly or just one specifically?

Upvotes: 0

Paras
Paras

Reputation: 9465

It's difficult to identify why your app is slow just through the routing code.

My suggestion is to install Laravel Debugbar. Then set the time datalogger to true (as 'time' => true in the config file) and enable DB timing (as 'timeline' => true in the config file). Once done, check the debugbar timing to understand where exactly the app is slow

Upvotes: 2

Related Questions