niji-digital/drupal-settings 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

niji-digital/drupal-settings

Composer 安装命令:

composer require niji-digital/drupal-settings

包简介

Composer Plugin for generate the Drupal settings file.

README 文档

README

Composer plugin for generate the Drupal settings.local.php (or other) file from a yaml parameter file.

Usage

  • Run composer require niji-digital/drupal-settings
  • Add new script to the scripts section of your composer.json:
{
  "scripts": {
    "prepare-settings": "NijiDigital\\Settings\\Plugin::generate"
  }
}
  • Create the YAML parameters file (by default in COMPOSER_ROOT/drupal-settings directory, see Parameters section)

  • Optional: Create the settings file template (see Template section)

  • Optional: Change the settings file destination (see Destination section)

  • Run composer prepare-settings

From "Template" using "Parameters" to "Destination"

All path parameters must be relative to the composer root directory

Template

By default the settings.local.php.twig template file present in this repository is used.

{% autoescape false %}
<?php

//$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
//$settings['cache']['default'] = 'cache.backend.null';
$settings['extension_discovery_scan_tests'] = TRUE;
$settings['file_chmod_directory'] = 0775;
$settings['file_chmod_file'] = 0664;
$settings['hash_salt'] = '{{ hash_salt }}';

$databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => '{{ db_name }}',
    'username' => '{{ db_user }}',
    'password' => '{{ db_pass }}',
    'host' => '{{ db_host }}',
    'port' => 3306,
    'prefix' => '',
    'collation' => 'utf8mb4_general_ci',
    'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
);

$config['system.logging']['error_level'] = '{{ error_level }}';
$config['system.performance']['css']['preprocess'] = {{ css_preprocess }};
$config['system.performance']['js']['preprocess'] = {{ js_preprocess }};
$config['system.performance']['cache.page.max_age'] = {{ cache_maxage }};

$settings['trusted_host_patterns'] = {{ trusted_host_patterns }};

$config_directories = array(
    CONFIG_SYNC_DIRECTORY => getcwd() . '/../config/'
);
{% endautoescape %}

You can make your own template and add his definition in the composer extra data definition:

{
    "extra": {
        "drupal-settings": {
            "template-directory": "path/to/templates",
            "template-file": "settings.local.php.twig"
        }
    }
}

Parameters

Example:

cache_maxage: '300'
css_preprocess: 'TRUE'
db_host: 'mariadb'
db_name: 'drupal'
db_pass: 'drupal'
db_user: 'drupal'
error_level: 'verbose'
js_preprocess: 'TRUE'
trusted_host_patterns:
  - '^drupal\.localhost$'

This plugin tried to load parameter file (in order):

  1. The file defined in composer extra data definitions:
{
    "extra": {
        "drupal-settings": {
            "parameters-file": "../path/to/parameters.yml"
        }
    }
}
  1. settings/parameters.yml
  2. settings/parameters.dist.yml

Destination

By default the settings.local.php file is created in the web/sites/default directory.

The destination can be overwritten in composer extra data definition.

{
    "extra": {
        "drupal-settings": {
            "destination-directory": "web/sites/default",
            "destination-file": "settings.local.php"
        }
    }
}

统计信息

  • 总下载量: 18.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 7
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2017-11-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固