{"id":683,"date":"2018-12-27T07:29:31","date_gmt":"2018-12-27T07:29:31","guid":{"rendered":"https:\/\/www.nethues.com\/blog\/?p=683"},"modified":"2022-07-21T10:39:41","modified_gmt":"2022-07-21T10:39:41","slug":"ways-to-optimize-the-performance-of-a-laravel-application","status":"publish","type":"post","link":"https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/","title":{"rendered":"Ways To Optimize The Performance Of A Laravel Application"},"content":{"rendered":"<p>Application development with Laravel has always been a pleasurable experience for developers. But just developing and delivering doesn\u2019t complete the job. Your app, once deployed, needs to deliver a seamless experience. For this, developers should underline the problem and focus on improving speed and performance.<\/p>\n<p>In order to achieve the desired results in Laravel development, a developer should follow some key strategies.<\/p>\n<p><em><i>Don\u2019t worry, we are for your rescue!<\/i><\/em><\/p>\n<p>After a detailed analysis and study, we have come up with a list of required strategies and ways to optimize the overall performance of your Laravel application.<em><i>\u00a0<\/i><\/em><\/p>\n<p><strong><b>Enhance Artisan\u00a0Command Uses<br \/>\n<\/b><\/strong>Laravel comes with a remarkable and unique tool named Artisan command which is highly beneficial in boosting performance. This is how the common setup goes:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-684 aligncenter\" src=\"https:\/\/www.nethues.com\/blog\/app\/uploads\/2018\/12\/Laravel.png\" alt=\"Laravel\" width=\"702\" height=\"175\" srcset=\"https:\/\/www.nethues.com\/blog\/app\/uploads\/2018\/12\/Laravel.png 702w, https:\/\/www.nethues.com\/blog\/app\/uploads\/2018\/12\/Laravel-300x75.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/>This proves to be very useful, especially when the <a href=\"https:\/\/www.nethues.com\/hire-laravel-developer\">Laravel developer <\/a>creates several routes and configuration along with a cache as a plain array. This helps in loading cache faster instead of loading the real object.<\/p>\n<p>But don\u2019t forget to re-run this command after you\u2019ve changed config or your routes file. Otherwise, Laravel won\u2019t handle the changes because it has already loaded from cache.<\/p>\n<p>Furthermore, we can cache the user data, settings and locations to limits the number of SQL queries. Make sure you invalidate the cache when the data changes. Also, you need to make sure that you have good indexes for your database, Cache your configs, routes and views. So add these commands to your Forge deploy script.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-685 aligncenter\" src=\"https:\/\/www.nethues.com\/blog\/app\/uploads\/2018\/12\/laravel-script.png\" alt=\"laravel script\" width=\"632\" height=\"164\" srcset=\"https:\/\/www.nethues.com\/blog\/app\/uploads\/2018\/12\/laravel-script.png 632w, https:\/\/www.nethues.com\/blog\/app\/uploads\/2018\/12\/laravel-script-300x78.png 300w\" sizes=\"(max-width: 632px) 100vw, 632px\" \/><\/p>\n<p>Install\/Setup PHP OPcache. OPcache will cache your PHP code and would leave no room for recompiling.<\/p>\n<p><strong>Remove Unused Service<\/strong><br \/>\nSometimes it is better to not load all services in your config and to disable unused services inside config file. It is recommended to add a comment to unused service provider in config\/app.php. However, make sure that after commenting, you don\u2019t end up breaking the entire functionality of your app.<\/p>\n<p><strong>Minimize Use Of Plugins\u00a0<\/strong><br \/>\nLaravel comes with a whole lot plugins that allow in adding more functionality in the simplest ways. With increased functionality comes more loadable libraries and files, which in turn might slow down the entire process. So make sure to take a look at the providers you are loading through your config\/app.php file and cut down unnecessary ones. Moreover, Laravel uses composer to manage its components, so eliminating the unnecessary parts from composer JSON file decreases the dependencies to be loaded.<\/p>\n<p><strong>JIT Compiler<\/strong><br \/>\nWe all know that PHP needs something to interpret the files and execute C routines. As you might guess, this is slow. Every time your server runs a PHP file, it has to convert it to tokens \u2013 done by the AST parser and interpret it. It, unfortunately, has to compile it every single time, even though it gets the same result.<\/p>\n<p>Thus, for your application to act fast, you need to compile it once, run it every time method, and fortunately, a JIT compiler does this the best.<\/p>\n<p>The widely used JIT compiler for Laravel is HHVM, created and used extensively by Facebook. It\u2019s also used by Wikipedia, Etsy and thousands of others.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This write-up has shown us various ways and techniques that can be used to optimize the performance of a Laravel application. So it\u2019s time for you to implement these in your applications and witness massive performance improvements. Hope you find this helpful.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Application development with Laravel has always been a pleasurable experience for developers. But just developing and delivering doesn\u2019t complete the job. Your app, once deployed,&#8230;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":7,"featured_media":686,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[127],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ways to optimize the performance of a laravel application<\/title>\n<meta name=\"description\" content=\"Application development with Laravel has always been a pleasurable experience for developers. But just developing and delivering doesn\u2019t complete the job.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ways to optimize the performance of a laravel application\" \/>\n<meta property=\"og:description\" content=\"Application development with Laravel has always been a pleasurable experience for developers. But just developing and delivering doesn\u2019t complete the job.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-12-27T07:29:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-21T10:39:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.nethues.com\/blog\/app\/uploads\/2018\/12\/Laravel-Application-Development.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1074\" \/>\n\t<meta property=\"og:image:height\" content=\"506\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sanjeev Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sanjeev Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ways to optimize the performance of a laravel application","description":"Application development with Laravel has always been a pleasurable experience for developers. But just developing and delivering doesn\u2019t complete the job.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/","og_locale":"en_US","og_type":"article","og_title":"Ways to optimize the performance of a laravel application","og_description":"Application development with Laravel has always been a pleasurable experience for developers. But just developing and delivering doesn\u2019t complete the job.","og_url":"https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/","article_published_time":"2018-12-27T07:29:31+00:00","article_modified_time":"2022-07-21T10:39:41+00:00","og_image":[{"width":1074,"height":506,"url":"https:\/\/www.nethues.com\/blog\/app\/uploads\/2018\/12\/Laravel-Application-Development.jpg","type":"image\/jpeg"}],"author":"Sanjeev Kumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sanjeev Kumar","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/","url":"https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/","name":"Ways to optimize the performance of a laravel application","isPartOf":{"@id":"https:\/\/www.nethues.com\/blog\/#website"},"datePublished":"2018-12-27T07:29:31+00:00","dateModified":"2022-07-21T10:39:41+00:00","author":{"@id":"https:\/\/www.nethues.com\/blog\/#\/schema\/person\/bcfb7e26c34e7ef5eafd93a0440c3204"},"description":"Application development with Laravel has always been a pleasurable experience for developers. But just developing and delivering doesn\u2019t complete the job.","breadcrumb":{"@id":"https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.nethues.com\/blog\/ways-to-optimize-the-performance-of-a-laravel-application\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.nethues.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Ways To Optimize The Performance Of A Laravel Application"}]},{"@type":"WebSite","@id":"https:\/\/www.nethues.com\/blog\/#website","url":"https:\/\/www.nethues.com\/blog\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.nethues.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.nethues.com\/blog\/#\/schema\/person\/bcfb7e26c34e7ef5eafd93a0440c3204","name":"Sanjeev Kumar","description":"A team leader by profession and movie lover by heart, Sanjeev is one of the intelligent brains at Nethues.","url":"https:\/\/www.nethues.com\/blog\/author\/sanjeevkumar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/posts\/683"}],"collection":[{"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/comments?post=683"}],"version-history":[{"count":8,"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions"}],"predecessor-version":[{"id":2606,"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions\/2606"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/media\/686"}],"wp:attachment":[{"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/media?parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/categories?post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nethues.com\/blog\/wp-json\/wp\/v2\/tags?post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}