Magento – Magento 2 : Development is extremely slow

developer-modedevelopmentmagento2magento2.2

I spent a lot of time learning core concepts, and now I have a decent understanding of Magento 2.

However I am spending days, not hours, trying to make even tiny changes, like changing layout, I need to run and wait a lot of time whenever I make any changes to my website.

Commands like clearing cache,upgrading modules,deploying static content.

If you have missed one of these commands, you can spend a couple of days trying to find anerror in your code, but finally will find out that there are some generated files that are cached.

I am spending hours to change something in Magento 2that is done in seconds using other CMSes.

Whenever I make a change and it is not applied, I need to guess whether it is cached or I had made a mistake in my code.

Please suggest any way to speed up development time

Best Answer

It is good that you spent a lot of time learning core concepts. But if you still need to guess, which step is missing if something you made does not work, you should probably spend more time learning the following concepts:

  • static content deployment
  • code generation
  • caching
  • indexing

If you have a decent knowledge of these topics, it is usually kind of clear what you need to do so that your changes take effect. Start with the devdocs on these topics and google a bit for more information.

However, here are some general tips on speeding up Magento 2 development:

  • Enable all caches and use Mage2 TV Cache Clean. This tool clears only the required caches if you change specific stuff in your module. Hence, you more often have cache hits and you need to flush the cache manually much more rare.
  • Use the developer mode. This generally helps, because you see error messages, warnings etc. But it also leads to the fact that static content is deployed on the fly and that it is not copied, but symlinked from your module. Hence, if you change a static file in your module, you do not need to run static content deployment.
  • If you use integration tests (you should!), use the ReachDigital Magento 2 Performance tuned integration tests. It speeds up the boot time for the integration tests.
  • If you use integration tests (you should!), disable the TESTS_CLEANUP variable. This way, the database is not completely rebuilt on each integration test rebuild. The disadvantage is of course that you need to do that manually from time to time. However, it speeds up the whole process a lot.
  • Use test driven development (TDD). This way, you need to call the Magento 2 frontend / backend more rare.
  • (personal preference and dependent on your company) Develop on your local machine if possible. This way, you avoid all possible performance issues with tools like Docker.
  • I am not a frontend guy, but my frontend guy says that using grunt for the less compilation is much faster then the default compilation.
  • I am not a frontend guy, but use a tool like LiveReload. It automatically refreshes the browser on CSS / LESS / SASS changes.
  • I am not a frontend guy, but use the H&O Magento 2 Advanced Template Hints module.

I hope this helps a bit. I will try to update the post from time to time.

Related Topic