定制 wearewondrous/psh-toolbelt 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

wearewondrous/psh-toolbelt

Composer 安装命令:

composer require wearewondrous/psh-toolbelt

包简介

Platform sh tools for a Drupal 10 and php 8.1.

README 文档

README

Build Status

Make the Drupal 9 installation highly configurable using:

  • Robo
  • Environment Variables

Todos

  • create task to recover a backup
  • allow switching from AWS to Google cloud
  • create packagist entry
  • write documentation for each Task

Installation

  $ composer require wearewondrous/psh-toolbelt

After you configured your environment with a robo.yml (described below). you can run:

  $ vendor/bin/psh-toolbelt

and see all available commands.

Configuration

sites/default/settings.php (required)

Overwrite the sites/default/settings.php with the given two includes.

<?php
// Default Drupal 9 settings.
//
// These are already explained with detailed comments in Drupal's
// default.settings.php file.
//
// See https://api.drupal.org/api/drupal/sites!default!default.settings.php/9
// customized project settings
include $app_root . '/../vendor/wearewondrous/psh-toolbelt/src/site.settings.php';
// Local settings. These come last so that they can override anything.
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
  include $app_root . '/' . $site_path . '/settings.local.php';
}

services

If your project needs to overwrite the default services use a file called local.services.yml

robo.yml.dist (required)

Copy over the default config from the robo.yml.dist in the project root, and name it robo.yml. All paths given are relative to project root. No trailing slashes. File wearewondrous/psh-toolbelt/robo.yml.dist contents:

storage:
  backup:
    max_age: 432000         # 60 * 60 * 24 * 5
  s3:
    version: new-latest
    region: eu-west-1
    upload_bucket: backups
platform:
  host: eu.platform.sh
  domain: my-website.com
  mounts:
    temp: tmp
    config: remote-config
drupal:
  hash_salt: 1234567890abcdefghijklmnopqlmnopqrstuvwxyz12345678
  config_sync_directory: config/drupal/default
  public_files_directory: web/sites/default/files
  private_files_directory: private
  excludes:
    - js
    - css
    - styles
    - translations
    - languages
    - config
  config:
    splits:
      default:
        machine_name: default
        folder: default
      prod:
        machine_name: production
        folder: prod
      dev:
        machine_name: development
        folder: dev
drush:
  alias_group: my-website
  alias: local
  path: vendor/bin/drush
lando:
  disable_cache: true
  host: my-website.lndo.site
  mysql:
    database: drupal
    hostname: 127.0.0.1
    password: drupal
    port: 3306
    user: drupal

Copy it in your root folder and rename it to robo.yml. Adjust to your needs. Normally, you only need to set it like this:

platform:
  domain: drupal-rocks.com
  host: eu.platform.sh
drush:
  alias_group: drupalrocks
lando:
  hash_salt: 1234567890abcdefghijklmnopqlmnopqrstuvwxyz12345678
  host: my-website.lndo.site

sites/default/settings.php (required)

See an example for a sites/default/settings.php, have a look at platformsh-template/drupal9. Before the include of the settings.local.php add the following:

// customized project settings
include $app_root . '/../vendor/wearewondrous/psh-toolbelt/src/site.settings.php';

Platform.sh Variables (required for backup-task)

The following variables are required to have the backup task working:

env:AWS_ACCESS_KEY_ID={aws_access_key_id}
env:AWS_SECRET_KEY_ID={aws_secret_key_id}
env:SENTRY_DSN={sentry_dsn}

Optionally, to backup a branch that is not master, add this to the platform.sh variables of the desired branch.

env:BACKUP_THIS_BRANCH=1

Note: optionally, the variables can live as actual environment variables or as Platform.sh variables.

composer.json and .env (optional)

For local development and tests with env vars, add to your root project composer.json:

{
  "autoload": {
    "files": ["vendor/wearewondrous/psh-toolbelt/load.environment.php"]
  }
}

Then copy wearewondrous/psh-toolbelt/.env.dist to the root of you project and rename it to .env. Exclude this file from your vcs. Do This only, if you want to mock production vars.

### Platform.sh VARS ############
#PLATFORMSH_CLI_TOKEN=
#PLATFORM_APP_DIR=/app
#PLATFORM_PROJECT=
#PLATFORM_ENVIRONMENT=
#PLATFORM_DOCUMENT_ROOT=/app/web
#PLATFORM_BRANCH=master

### Required VARS ###############
# AWS config
AWS_ACCESS_KEY_ID=
AWS_SECRET_KEY_ID=
# Logging
SENTRY_DSN=

Troubleshooting

Make sure to have the following mounts in your platform.app.yaml. Otherwise you will run in errors on the server, like Could not create directory '/app/.ssh'.

mounts:
  '/web/sites/default/files': 'shared:files/files'
  '/tmp': 'shared:files/tmp'
  '/private': 'shared:files/private'
  '/.drush': 'shared:files/.drush'
  '/remote-config': 'shared:files/remote-config'

wearewondrous/psh-toolbelt 适用场景与选型建议

wearewondrous/psh-toolbelt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.69k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「platform.sh」 「lando」 「php 8.1」 「drupal-10」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 wearewondrous/psh-toolbelt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wearewondrous/psh-toolbelt 我们能提供哪些服务?
定制开发 / 二次开发

基于 wearewondrous/psh-toolbelt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2019-04-24