Code compiler

In addition to the command arguments described in this topic, see Common arguments.

Run all Magento CLI commands as the Magento file system owner.

Code compilation includes the following (in no particular order):

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

You can find code compilation classes in the \Magento\Setup\Module\Di\App\Task\Operation namespace.

The Magento software does not support the multi-tenant compiler, which includes the bin/magento setup:di:compile-multi-tenant command.

To run the single-tenant compiler:

bin/magento setup:di:compile

Generated code and dependency injection configuration successfully.

To compile code before installing the Magento application:

In some cases, you might want to compile code before you install the Magento application.

  1. Enable the modules.

    php bin/magento module:enable --all [-c|--clear-static-content]
    

    Use the [-c|--clear-static-content] option to clear static content. This is necessary if you previously enabled or disabled modules and you must clear the static content previously generated for them.

    See Enable modules.

  2. Compile the code.

    bin/magento setup:di:compile
    
    Generated code and dependency injection configuration successfully.
    

To compile code without a database, see Deploy static view files without installing Magento.