PHPackages                             vardot/module-installer-factory - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vardot/module-installer-factory

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vardot/module-installer-factory
===============================

Module Installer Factory

1.0.4(1y ago)3165.2k↓13.8%11GPL-2.0-or-laterPHP

Since Mar 23Pushed 1y ago3 watchersCompare

[ Source](https://github.com/Vardot/module-installer-factory)[ Packagist](https://packagist.org/packages/vardot/module-installer-factory)[ Docs](https://github.com/Vardot/module-installer-factory)[ RSS](/packages/vardot-module-installer-factory/feed)WikiDiscussions 1.0.x Synced 3d ago

READMEChangelog (6)Dependencies (1)Versions (11)Used By (1)

Module Installer Factory Class
==============================

[](#module-installer-factory-class)

Provides developers with a class for modules installer factory.

This class is working with `module_name.info.yml` file with any modules key.

Let us have the `module_name.info.yml` with the following items under `install` key for example:

```
name: "Module Name"
description: "Module description."
type: module
core_version_requirement: ^9
dependencies:
  - drupal:node
  - drupal:editor
  - drupal:ckeditor
  - drupal:filter
install:
  - extlink
  - linkit
  - anchor_link

```

So that the installed modules could be disabled in some projects without the need to disable the used module.

It's installed only not a dependency.

How to use the Module Installer Factory Class
---------------------------------------------

[](#how-to-use-the-module-installer-factory-class)

1. Require the Package in your root composer.json file
------------------------------------------------------

[](#1-require-the-package-in-your-root-composerjson-file)

```
  "vardot/module-installer-factory": "~1.0"

```

Or require the Package in your Project with a command

```
$ composer require vardot/module-installer-factory:~1.0

```

2. Add Needed Namespace
-----------------------

[](#2-add-needed-namespace)

Add the following namespace in custom modules or custom installation profiles.

```
use Vardot\Installer\ModuleInstallerFactory;

```

Use the following methods in your custom install events
-------------------------------------------------------

[](#use-the-following-methods-in-your-custom-install-events)

### Install a list of modules

[](#install-a-list-of-modules)

Install the list of module in the varbase\_core.info.yml

```
  ModuleInstallerFactory::installList('varbase_core');

```

### **Arguments for** installList method\*\*:\*\*

[](#arguments-for-installlist-method)

- `String` **$moduleName:** The machine name for the module.
- `String` **$modulesListKey:** Optional list key which to get the list of modules from. Default 'install'. It can be changed on managed cases like (managed, when\_module\_name\_enabled)
- `Boolean` **$setModuleWeight:** A flag to auto set the weight of the module after installation of a list of modules.

which is equivalent to:

```
  ModuleInstallerFactory::installList('varbase_core', 'install', TRUE);

```

### Set the weight of the module after installation of the list of modules

[](#set-the-weight-of-the-module-after-installation-of-the-list-of-modules)

To make sure that any hook or event subscriber works after all used modules.

```
  ModuleInstallerFactory::setModuleWeightAfterInstallation('varbase_core', 'install');

```

### **Arguments for** setModuleWeightAfterInstallation\*\*:\*\*

[](#arguments-for-setmoduleweightafterinstallation)

- `String` **$moduleName:** The machine name for the module.
- `String` **$modulesListKey:** Optional list key which to get the list of modules from. Default
- `Array` **$modules:** Optional list of modules in an array.

To set the weight of the module after listed modules with a selected set of modules for example: If the `varbase_core.info.yml` file had

```
set_weight_after:
  - ctools
  - token
  - block_class

```

even tho if the module did not enable them.

```
  ModuleInstallerFactory::setModuleWeightAfterInstallation('varbase_core', 'set_weight_after');

```

or can be passed as an array as follows:

```
  ModuleInstallerFactory::setModuleWeightAfterInstallation('varbase_core', '', ['ctools', 'token', 'block_class']);

```

At this point any hook or event subscriber will be processed after the listed modules.

### Import configuration from scaned directory

[](#import-configuration-from-scaned-directory)

### **Example 1:** Import all field storage configs

[](#example-1-import-all-field-storage-configs)

```
  ModuleInstallerFactory::importConfigsFromScanedDirectory('varbase_core', '/^field.storage.*\\.(yml)$/i', 'config/optional');

```

### **Example 2:** Import all custom settings files from a managed folder in the module.

[](#example-2-import-all-custom-settings-files-from-a-managed-folder-in-the-module)

```
  ModuleInstallerFactory::importConfigsFromScanedDirectory('varbase_security', '/^.*(settings.yml)$/i', 'config/managed');

```

### Import configuration from array list of config files

[](#import-configuration-from-array-list-of-config-files)

### **Example 1: Import configs from a managed config folder**

[](#example-1-import-configs-from-a-managed-config-folder)

```
  ModuleInstallerFactory::importConfigsFromList('varbase_admin',
  [
    'views.view.content',
    'views.view.user_admin_people',
  ],
  'config/managed');

```

### **Arguments for** importConfigsFromList method\*\*:\*\*

[](#arguments-for-importconfigsfromlist-method)

- `String` **$moduleName:** The machine name for the module.
- `Array` **$listOfConfigFiles:** The list of config files.
- `String` **$configDirectory:** The config directory which to partial import the list from.

It could be used in some cases to change the default View for the Content or People with multilingual sites or extra filters by other modules. It is important which manage the `Assemble components and install` installation step.

### **Example 2: In Use Import of Configs**

[](#example-2-in-use-import-of-configs-)

Having a custom config for a disabled module, which will be Enabled and Disabled many times with development and deployments, but they need to have the basic extra change for config over the default settings or configs for the used module.

```
/**
 * Implements hook_modules_installed().
 */
function varbase_security_modules_installed($modules, $is_syncing) {
  if (in_array('security_review', $modules)) {
    // The module will be Enabled and Disabled many times
    // with development and deployments to production sites.
    // But the need to have the basic extra change for config over
    // the Security Review default configs.
    // -------------------------------------------------
    // Managed configs for the Security Review module.
    $managed_configs = [
      'security_review.settings',
      'security_review.check.security_review-admin_permissions',
      'security_review.check.security_review-error_reporting',
      'security_review.check.security_review-executable_php',
      'security_review.check.security_review-failed_logins',
      'security_review.check.security_review-field',
      'security_review.check.security_review-file_perms',
      'security_review.check.security_review-input_formats',
      'security_review.check.security_review-private_files',
      'security_review.check.security_review-query_errors',
      'security_review.check.security_review-temporary_files',
      'security_review.check.security_review-trusted_hosts',
      'security_review.check.security_review-upload_extensions',
      'security_review.check.security_review-views_access',
    ];

    // Import managed configs to the site active configs.
    ModuleInstallerFactory::importConfigsFromList('varbase_security', $managed_configs, 'config/managed/security_review');

    // Entity updates to clear up any mismatched entity and/or field definitions
    // And Fix changes were detected in the entity type and field definitions.
    \Drupal::classResolver()
      ->getInstanceFromDefinition(EntityDefinitionUpdateManager::class)
      ->applyUpdates();
  }
}

```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance40

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~106 days

Recently: every ~260 days

Total

11

Last Release

502d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1641992?v=4)[Rajab Natshah](/maintainers/Natshah)[@Natshah](https://github.com/Natshah)

![](https://www.gravatar.com/avatar/0a7204f4105511c0cbdfa7f4bf05ce8d7ddb14b26053a1b50e17895c23da12b4?d=identicon)[vardot-devops](/maintainers/vardot-devops)

---

Top Contributors

[![Natshah](https://avatars.githubusercontent.com/u/1641992?v=4)](https://github.com/Natshah "Natshah (22 commits)")

### Embed Badge

![Health badge](/badges/vardot-module-installer-factory/health.svg)

```
[![Health](https://phpackages.com/badges/vardot-module-installer-factory/health.svg)](https://phpackages.com/packages/vardot-module-installer-factory)
```

###  Alternatives

[farmos/farmos

A web-based farm record keeping application.

1.3k7.1k1](/packages/farmos-farmos)[emulsify-ds/emulsify-drupal

The official Drupal theme for Emulsify, with Storybook and a Vite-based build workflow for generated child themes

96556.4k2](/packages/emulsify-ds-emulsify-drupal)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
