You are here

README.txt in Configuration Read-only mode 8

CONTENTS OF THIS FILE
 ---------------------
  * Introduction
  * Requirements
  * Installation
  * Configuration

 INTRODUCTION
 ------------
 This module attempts to block all Drupal configuration changes.

 The main use case is to lock configuration on a production site and import
 config using drush that has been validated on a testing copy of the site.

 REQUIREMENTS
 ------------
 No special requirements.

 INSTALLATION
 ------------
 Install as you would normally install a contributed Drupal module. Visit:
 https://www.drupal.org/documentation/install/modules-themes/modules-8
 for further information.

 CONFIGURATION
 -------------
 To set a site in read-only mode add this to setting.php:

     $settings['config_readonly'] = TRUE;

 To provide a whitelist of configuration that can be changed when in read-only
 mode add this to settings.php:

     $settings['config_readonly_whitelist_patterns'] = [
       'config_name.to.ignore',
       'wildcards*allowed',
     ];

 Or implement the hook:

     hook_config_readonly_whitelist_patterns() {
       return [
         'config_name.to.ignore',
         'wildcards*allowed',
       ];
     }

 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;
     }

File

README.txt
View source
  1. CONTENTS OF THIS FILE
  2. ---------------------
  3. * Introduction
  4. * Requirements
  5. * Installation
  6. * Configuration
  7. INTRODUCTION
  8. ------------
  9. This module attempts to block all Drupal configuration changes.
  10. The main use case is to lock configuration on a production site and import
  11. config using drush that has been validated on a testing copy of the site.
  12. REQUIREMENTS
  13. ------------
  14. No special requirements.
  15. INSTALLATION
  16. ------------
  17. Install as you would normally install a contributed Drupal module. Visit:
  18. https://www.drupal.org/documentation/install/modules-themes/modules-8
  19. for further information.
  20. CONFIGURATION
  21. -------------
  22. To set a site in read-only mode add this to setting.php:
  23. $settings['config_readonly'] = TRUE;
  24. To provide a whitelist of configuration that can be changed when in read-only
  25. mode add this to settings.php:
  26. $settings['config_readonly_whitelist_patterns'] = [
  27. 'config_name.to.ignore',
  28. 'wildcards*allowed',
  29. ];
  30. Or implement the hook:
  31. hook_config_readonly_whitelist_patterns() {
  32. return [
  33. 'config_name.to.ignore',
  34. 'wildcards*allowed',
  35. ];
  36. }
  37. To lock production and not other environments, your code in settings.php
  38. might be a conditional on an environment variable like:
  39. if (isset($_ENV['AH_SITE_ENVIRONMENT']) && $_ENV['AH_SITE_ENVIRONMENT'] === 'prod') {
  40. $settings['config_readonly'] = TRUE;
  41. }
  42. The following approaches are somewhat discouraged since they may allow anyone
  43. with drush or shell access to bypass or disable the protection and change
  44. configuration in production.
  45. To allow all changes via the command line and enable readonly mode for the UI only:
  46. if (PHP_SAPI !== 'cli') {
  47. $settings['config_readonly'] = TRUE;
  48. }
  49. You could similarly toggle read-only mode based on the presence or absence of
  50. a file on the webserver (e.g. in a location outside the docroot).
  51. if (!file_exists('/home/myuser/disable-readonly.txt')) {
  52. $settings['config_readonly'] = TRUE;
  53. }