Code compiler
In addition to the command arguments described in this topic, see Common arguments.
Run all Magento CLI commands as 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:
1
bin/magento setup:di:compile
1
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.
-
Enable the modules.
1
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.
-
Compile the code.
1
bin/magento setup:di:compile
1
Generated code and dependency injection configuration successfully.
To compile code without a database, see Deploy static view files without installing Magento.