Worse, wading through the above list requires a lot of related material and related topics (like configuration management). But as you start trying to learn about Drupal it’s highly likely to find conflicting information about “how best” to accomplish this task. Do you need to know “all” of these ways to be successful with Drupal? Definitely not. This is one of the many reasons that Drupal is “so hard” to learn. Drush is technically used to run the config import at that point (which I didn’t put on the list, because drush cim enables modules via and config split, so it felt like cheating). Featuresįeatures are basically modules so this really runs the risk of being a dup of #3 but given that Features has its own UI and commands for managing its processes, I think it’s still worth calling it out as a way to do it!ĭid I miss any? I think 12 is a pretty long list of ways to do something like “turn on a module.”įor me, on most projects, I use core.extensions to manage my enabled modules and config split to toggle them on / off. Then, when the split gets turned on and config is synchronized then the additional module(s) get enabled. When you define a config split (conditional config) you can toggle modules on as part of the split. \Drupal::service('module_installer')->install() 11. Usually you’d want to do this during a cron job or. Module Installer Service (code)ĭrupal 8/9 ships with a handy module_installer service that can be called in PHP. The same as #7 just with Drupal Console instead of Drush. Legacy versions of drush have the “drush_invoke_process” command which was recently deprecated and replaced with the Drush::drush() command. Drush Install (code)ĭid you know you can call drush with PHP and then execute drush commands in your code? Well you can! I don’t really think you “should” (because Drupal ships with its own module installer service, see #10) BUT you “can” do it this way. Obviously this requires Drush to be present / installed and like #1 (enabling via the Admin UI) this is quite volatile as the module’s enabled state won’t survive a config import / sync unless you capture the config change. One of the most common “non-Drupal” core ways to turn on a module is drush pm-enable (or drush en). The install list will turn on a bunch of modules but will not make them dependencies (meaning that you can uninstall them later). This one is “similar” to #3 but has one significant difference. Same as #3 but in the profile’s info.yml. Module DependencyĮvery module’s info.yml file can (and probably should) contain a dependencies key that makes your module reliant on “other modules.” When you turn on your module, your module will automatically enable all of those other dependencies. You can enable modules by adding them to this list and doing a config import / sync. If you are taking advantage of a configuration management strategy, all of your modules will get dumped out into a nicely formatted list in the file inside your config dump. It also is one of the most volatile ways of enabling a module since you are directly manipulating active configuration (and if you have a configuration management strategy in place, the next time you deploy config the module will get disabled again). While likely the “simplest” way on this list, it definitely isn’t the fastest. Log in as an admin and go turn it on in the UI. I’m not sure all of them are “valid” but all of them work! You wouldn’t (or shouldn’t) use “all” of these methods on the same project. There are modules (like Config Split and Features) and there are tools (like Drush and Drupal Console) to consider.įinally, I recognize that many of these methods would supersede other methods on the list. I AM counting community contributions in this regard. We can safely assume that the modules are present when you go to enable them. downloading tar files or using composer). I am not counting any method of “adding modules to the code base” (e.g. It’s not my fault that 3 people could do the “same thing” in 3 totally different ways. HOWEVER there are duplicates on this list because that duplication exists in Drupal. I 100% recognize as you read this list, there may be some things that you say “Now Mike, those are actually the same thing.” And I agree! There are duplicates on this list.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |