Code compiler

WARNING
All Magento CLI commands must be run by the 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.

To run the single-tenant compiler:

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

To compile code before installing the Commerce application:

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

  1. Enable the modules.

    code language-bash
    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.

    code language-bash
    bin/magento setup:di:compile
    
    code language-none
    Generated code and dependency injection configuration successfully.
    

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

recommendation-more-help
386822bd-e32c-40a8-81c2-ed90ad1e198c