As a Magento developer, you know that enabling a Magento module can be done via the command bin/magento module:enable Foo_Bar. However, this does not take module dependencies properly into account. Because of this shortcoming, this document discusses different means to enable modules and all their dependencies.
Module dependencies are not properly tracked by Magento. When you enable module Example_A which has a dependency with module Example_B, enabling module Example_A does not automatically enable module Example_B. Within the etc/module.xml file of module Example_A, the XML node <sequence> points to other modules to be loaded before module Example_A. But that <sequence> is not necessarily a dependency tree.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Example_A">
<sequence>
<module name="Example_B"/>
</sequence>
</module>
</config>
With Loki, we tend to treat the <sequence> as a dependency tree anyway. If a module Example_A mentions a module Example_B in its <sequence>, both modules should be enabled.
bin/magento setup:upgradeA lot of Magento developers bump into this. And the usual approach is to just run the CLI command bin/magento setup:upgrade. This command runs the database upgrade scripts. But - coincidentally - it also enables any module that is detected and that is not yet registered in app/etc/config.php yet.
This is not wrong. It is just that running database upgrades to just enable a module feels a bit off.
Another mechanism might be to use the output of one command bin/magento module:status | grep Loki as the input of another command bin/magento module:enable.
This enables all modules with the word Loki in them:
bin/magento module:enable `bin/magento module:status | grep Loki`
This enables all modules with the word Loki or Yireo in them:
bin/magento module:enable `bin/magento module:status | grep -E 'Yireo|Loki'`
Another solution is to use a separate command that does the job better. The Yireo_EnableModuleSequence offers a command module:sequence that tracks down the <sequence> of a given module. And the sequence of those modules. And the sequence of those modules. And then enables them all:
bin/magento module:sequence LokiCheckout_Core
See https://github.com/yireo/Yireo_EnableModuleSequence