Magento Tutorials

How to Run Compile Command Line in Magento 2

Hello Magento Friends,

In this tutorial blog post, I will clarify How to Run Compile Command Line in Magento 2. 

When the compilation process takes a longer time than usual, you need to run the compile command (setup:di:compile) in Magento 2. Usually, the compilation process takes a long time when the changes have been made at proxy js, factory methods, or other code. So if you feel you have made a lot of changes in your configuration and found the compilation process slows down, it’s time to run the setup:di:compile command.

What does the setup:di:compile command do?

The setup:di:compile command will perform the following things:

  • Application code generation – for factories, proxies
  • Interceptor generation – improve code generation of interceptors
  • Interception cache generation – improve cache generation of interceptors
  • Area configuration aggregation – improve dependency injection configurations per area
  • Repositories code generation – create code for APIs
  • Service data attributes generation – create extension classes for data objects

Now, let’s see How to Run Compile Command Line in Magento 2.

Steps to Run Compile Command Line in Magento 2:

Go to Magento Root Folder and run the help command to know what compile command does

php bin/magento setup:di:compile --help

It will display output as below:

Description:
   Generates DI configuration and all missing classes that can be auto-generated

Usage:
   setup:di:compile

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Now run the compile command from Magento Root Folder

php bin/magento setup:di:compile

The above command will show the output as below.

Compilation was started.
Plugin list generation... 9/9 [============================] 100% 46 secs 428.0 MiB
Generated code and dependency injection configuration successfully.

Conclusion:

Pretty easy! Right? This way you can Run Compile Command Line in Magento 2. Add your queries in the comment box and stay on track with us! Hire Magento Developer to fix your site issues quickly.

Let your friends know about the compile command for Magento 2 by sharing the article with them. 

Happy Reading!

Click to rate this post!
[Total: 6 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

Magento 2: How To Call JS on the Checkout Page?

Hello Magento mates, Today we will learn to add a call JS on the checkout…

3 days ago

Boost Your SEM Game: Unveiling the Top 10 Tools for Marketers in 2024

Business survival in today’s digital world has become extremely difficult. Using traditional marketing techniques is…

4 days ago

Five Essential Payroll Compliance Tips for eCommerce Startups

Are you setting up a payroll system for your eCommerce startup? Ensuring compliance with myriad…

5 days ago

Optimizing Laravel Blade: Unlocking Advanced Fetcher Techniques

In the expansive universe of Laravel development, Blade serves as the stellar templating engine, propelling…

5 days ago

Magento 2: Add Quantity Increment and Decrement on Category Page

Hello Magento Friends, In this blog, we will discuss about adding quantity increment and decrement…

7 days ago

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

1 week ago