
Magento 2 comes with many changes, and one of the major changes in Magento 2 is the usage of dependency injection and dependency report patterns. With these patterns, a lot has changed inside the codebase, and many new things have been introduced. In this article, I am going to talk about Dependency reports and how you can run them in Magento 2.
In Magento 2, there are three types of dependencies reports, they are:
- Module dependencies: It shows the total number of dependencies among modules and whether the dependencies are hard or delicate.
- Circular dependencies: It shows the total number of dependency chains and circular dependency for modules.
- Framework dependencies: It shows the number of dependencies on the Magento 2 framework by a module.
Preparing To Run Dependency Reports
Before run dependency reports, you need to follow these steps:
- Login to the Magento 2 server and switch to a user who has permissions to write Magento 2 file system.
- Open your SSH terminal and use the following command to switch to the Magento 2 file system owner:
find . -type d -exec chmod 770 {} \; && find . -type f -exec chmod 660 {} \; && chmod u+x bin/magento export PATH=$PATH:$(pwd)/bin
Run Dependency Reports
For running the dependency reports on your Magento 2, use this following command:
magento info:dependencies:{show-modules|show-modules-circular|show-framework} [-d|--directory=""] [-o|--output="
Confused as to what these commands mean? Here are the meanings of this commands options, values, and parameters:
- show-modules: This Parameter is required for getting module dependencies report.
- show-modules-circular: This Parameter is required for getting Circular dependencies report.
- show-framework: This Parameter is required for getting Framework dependencies report.
Module Dependencies Report
Below is the output for a module dependencies report:
"","All","Hard","Soft" "Total number of dependencies","602","587","15" "Dependencies for each module:","All","Hard","Soft" "magento/module-cron","2","2","0" " -- magento/module-config","","1","0" " -- magento/module-store","","1","0" "magento/module-catalog-rule","8","8","0" " -- magento/module-store","","1","0" " -- magento/module-rule","","1","0" " -- magento/module-catalog","","1","0" " -- magento/module-customer","","1","0" " -- magento/module-backend","","1","0" " -- magento/module-eav","","1","0" " -- magento/module-indexer","","1","0" " -- magento/module-import-export","","1","0"
Circular Dependencies Reports:
Below is the output for a circular dependencies report:
"Circular dependencies:","Total number of chains" "","848" "Circular dependencies for each module:","" "magento/module-config","70" "magento/module-config->magento/module-store->magento/module-directory->magento/module-config" "magento/module-config->magento/module-store->magento/module-config" "magento/module-config->magento/module-cron->magento/module-config" "magento/module-config->magento/module-email->magento/module-config" "magento/module-config->magento/module-backend->magento/module-theme->magento/module-customer->magento/module-eav->magento/module-config" "magento/module-config->magento/module-backend->magento/module-reports->magento/module-config" "magento/module-config->magento/module-backend->magento/module-sales->magento/module-catalog->magento/module-theme->magento/module-eav->magento/module-config" "magento/module-config->magento/module-backend->magento/module-sales->magento/module-catalog->magento/module-log->magento/module-eav->magento/module-config" "magento/module-config->magento/module-backend->magento/module-sales->magento/module-customer->magento/module-checkout->magento/module-catalog-inventory->magento/module-config" "magento/module-config->magento/module-backend->magento/module-sales->magento/module-customer->magento/module-checkout->magento/module-config" "magento/module-config->magento/module-backend->magento/module-sales->magento/module-customer->magento/module-theme->magento/module-config" "magento/module-config->magento/module-backend->magento/module-sales->magento/module-payment->magento/module-config" "magento/module-config->magento/module-backend->magento/module-sales->magento/module-checkout->magento/module-customer->magento/module-review->magento/module-catalog->magento/module-themeax->magento/module-config" "magento/module-config->magento/module-backend->magento/module-sales->magento/module-checkout->magento/module-customer->magento/module-review->magento/module-catalog->magento/module-catalog-rule->magento/module-rule->magento/module-eav->magento/module-config"
Framework Dependencies Reports:
Below is the output for a framework dependencies report:
"Dependencies of framework:","Total number" "","111" "Dependencies for each module:","" "Magento\Cron","1" " -- Magento\Framework","143" "Magento\CatalogRule","1" " -- Magento\Framework","234" "Magento\Webapi","2" " -- Magento\Framework","347" " -- Magento\Server","1" "Magento\Checkout","1" " -- Magento\Framework","759" "Magento\Reports","1" " -- Magento\Framework","553"
Final Thoughts
This is just a short tutorial on how to run and prepare your Magento 2 framework for dependencies. I’m sure with this tutorial you can easily run dependencies report on your Magento 2 server. If you face any problems, leave your comment in the section below.