Skip to content

Instantly share code, notes, and snippets.

View hamog's full-sized avatar
😃

Hashem Moghaddari hamog

😃
View GitHub Profile
@hamog
hamog / optimizing-laravel-eloquent-queries.md
Last active October 28, 2023 08:51
Optimizing Laravel Eloquent queries

Published: Oct 28, 2023 by Hamog

Here are a few tips and tricks that I have learnt along the way to help optimize your database queries in Laravel. Sometimes, little changes can add up and make a big difference overall.

Select only the fields you need

Adding a select() to your query means that you only retrieve the fields that you are going to use, rather than returning every field in your model. If your view doesn’t need the field then save some memory by only fetching and returning the fields you need.

Rather than:

@hamog
hamog / laravel_deploy.md
Last active September 10, 2019 13:38
Deploy laravel 5 application on shared hosting.

Deploy Laravel 5 application on shared hosting

Server Requirements (Laravel 5.4)

  • PHP >= 5.6.4
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension
@hamog
hamog / laravel_optimize.md
Last active April 20, 2017 14:46
Laravel Optimization

Laravel Optimization

Adding up to all the tips you received here, here is what I generally do to increase my app's performance

1-Use a session driver like redis or memcached

2-Use one of these drives for caching also

3-Use cached query results for all the queries that are not volatile (not subject to change frequently)