This module prevents configuration changes from being made through the Drupal admin interface, which is useful for locking down production environments. It can be enabled via settings.php and offers options to allow command-line changes or exclude specific forms from read-only mode.
This module allows to lock any configuration changes done via the Drupal admin UI. This can be useful in scenarios where for example configuration changes should not be done on the production environment, but only on staging or local environments.
To enable readonly mode, enable this module and add this to your settings.php:
$settings['config_readonly'] = TRUE;
To lock production and not other environments, your code in settings.php
might be a conditional on an environment variable like:
if (isset($_ENV['AH_SITE_ENVIRONMENT']) && $_ENV['AH_SITE_ENVIRONMENT'] === 'prod') {
$settings['config_readonly'] = TRUE;
}
The following approaches are somewhat discouraged since they may allow anyone with Drush or shell access to bypass or disable the protection and change configuration in production.
To allow all changes via the command line and enable readonly mode for the UI only:
if (PHP_SAPI !== 'cli') {
$settings['config_readonly'] = TRUE;
}
You could similarly toggle read-only mode based on the presence or absence of a file on the webserver (e.g. in a location outside the docroot).
if (!file_exists('/home/myuser/disable-readonly.txt')) {
$settings['config_readonly'] = TRUE;
}
You may whitelist forms so that their config may be changed on the live site. See the following documentation for more information:
https://git.drupalcode.org/project/config_readonly/blob/HEAD/README.txt
Ask your assistant about Configuration Read-only mode
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
2 tracked projects depend on this one
- Config Ignore Readonly 919 sites
- Config Readonly Menu UI 173 sites
Activity
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 8.x-1.0 | Stable | 9–11 | Jul 2, 2024 | ||
| 8.x-1.0-beta5 | Pre-release | 9–10 | Jan 13, 2023 |