Improving the Performance of your Laravel Application — 3 Easy TipsWelcmBlockedUnblockFollowFollowingNov 6, 2018What is Laravel?Laravel is now widely recognised as the number one PHP framework for web applications.
Its open source nature and popularity amongst the development community means that all manner of businesses have chosen Laravel for one of more of their systems, from startups, to software development agencies, to large corporates such as the BBC and Crowdcube.
Why is optimisation important?As systems grow in numbers of users, amount of stored data and complexity, it is possible that performance bottlenecks can creep into a system.
Users of business-critical systems will need them to be fast and reliable to avoid having an impact on business performance.
Luckily there are several very simple steps that Laravel developers can take to significantly reduce the server overhead of applications and therefore improve their speed and reliability.
PrerequisitesIt’s always advised to be as up-to-date with your development frameworks as possible, therefore it’s recommended your application environment is at least:PHP 7.
7MySQLTo check your current Laravel version, at the command line, enter:php artisan –versionIf you’re not up to date we’ll be posting our upgrade guide in due course.
Three simple steps for improving performance1.
Cache your configThis means Laravel is not reading the application configuration from the config files on every load, and can provide a noticeable performance boost.
To enable this, at the command line enter:php artisan config:cacheDon’t forget to re-run this if you make any changes to configuration files.
If you need to clear the cache and disable this feature, enter:php artisan config:clear2.
Cache your web routesApplications with a number of pages/routes can benefit from caching the route files, similar to above, to enable this, enter:php artisan route:cacheDon’t forget to re-run this if you make any changes to route files.
If you need to clear the cache and disable this feature, enter:php artisan route:clear3.
Cache API routesMost applications will have some level of API functionality.
Depending on your approach to building your API, there may be options for specifically caching API routes.
If using the Dingo API package for example, running the following command will cache your application’s API routes:php artisan api:cacheDon’t forget to re-run this if you make any changes to API route files.
If you need to clear the cache and disable this feature, enter:php artisan api:clearFurther improvements1.
Cache sessions and queriesQueries can be cached using a suitable cache driver, the key options being a database cache driver, Memcached or Redis.
Going into details will require another article which will be coming in due course but the Laravel Docs provide a great primer.
Separate application and database serversThis again would require a separate article to explain in detail but by separating the application logic files from the database will significantly reduce the server load for each, improving application response times.
ConclusionWe hope this helps if you want to take a proactive approach to improving your application’s performance.
We’re big fans of Laravel here at Welcm, but we’re even bigger fans of businesses using fast, reliable software to help them perform at their best.
If you have applications in your business that are old, no longer supported, or are struggling with performance then get in touch to find out how we can help.
Like this story?.Please follow us on Twitter.
At Welcm we design, develop and support touch screen applications and systems.
If you have a project you would like to discuss please send an enquiry from our contact page, email us at enquiries@welcm.
uk or call us on 01252 950 650.
We also make Visitor Management Easy at https://welcm.