wunderio/ddev-drupal 问题修复 & 功能扩展

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

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

wunderio/ddev-drupal

Composer 安装命令:

composer require wunderio/ddev-drupal

包简介

Wunder's extendable template for DDEV Drupal projects.

README 文档

README

This project extends the standard DDEV setup with additional functionality and tools specifically designed for Drupal development. It provides a set of custom commands, configurations, and automation scripts to enhance your Drupal development workflow.

Features

Custom DDEV Commands

  • pmu: Runs drush pmu commands and creates dummy module folders if they don't exist. This helps to uninstall module that has gone missing for example during branch switching.
    ddev pmu module1 module2 ...
  • twig-debug: Toggles Drupal Twig debugging on/off. Useful for template development.
    ddev twig-debug        # Enable Twig debugging
    ddev twig-debug off    # Disable Twig debugging
  • grumphp: Runs GrumPHP commands
    ddev grumphp
  • phpunit: Runs PHPUnit commands
    ddev phpunit
  • codecept: Runs codeception commands
    ddev codecept
  • phpcbf: Runs phpcbf commands
    ddev phpcbf
  • phpcs: Runs PHPcs commands
    ddev phpcs
  • regenerate-phpunit-config: Regenerates fresh PHPUnit configuration
    ddev regenerate-phpunit-config
  • syncdb: Synchronizes local database with production. For production you should have a prod alias set in drush/sites/self.site.yml
    ddev syncdb
  • yq: Runs yq commands (YAML processor) It's available inside DDEV, but we expose it to host because why not :). It's required in syncdb script, but it could prove useful in day to day work.
    ddev yq

Enhanced Configuration

  1. Custom DDEV Configuration

    • Post-start scripts for both host and web containers - by default it gives you uli link.
    • Automatic update checks for this package
  2. Performance Optimizations

    • Special database_dumps/ directory for Mac users not to mount db dumps

Automated Workflows

The project includes several automated workflows:

  1. Database Management

    • Post-import database hooks (clears cache, sanitizes database)
    • Post-restore snapshot hooks (clears cache, sanitizes database)
    • Database synchronization from production
  2. Development Environment Setup

    • Automatic composer installation on first start
    • Post-start hook that run drush uli
    • Integration with Wunderio's development tools eg grumphp, phpunit

Both custom commands and hooks are scripts under dist/.ddev/wunderio/core/ folder and you can extend them if you copy particular script to dist/.ddev/wunderio/custom/. This folder is never overwritten during autoupdate.

Requirements

Installation

  1. Initialize your Drupal 10 project. Project name parameter is optional, but it's advisable to use domain name as your project name as that's used for for the subdomain of ddev.site eg if project name is example.com, then localhost URL will become example.com.ddev.site.

    ddev config --project-type=drupal10 --docroot=web --project-name=example.com
  2. Install wunderio/ddev-drupal Composer package with DDEV and restart DDEV:

    ddev composer require wunderio/ddev-drupal --dev && ddev restart
  3. Ignore this composer plugin managed files from the repo by adding following entries to .gitignore:

.ddev/wunderio/core
.ddev/commands/*/wunderio-core-*
  1. Add changes to GIT (note that below command uses -p, so you need to say 'y'es or 'n'o if it asks what to commit):

    git add .ddev/ &&
    git add drush/sites/ &&
    git add composer.lock &&
    git add -p composer.json web/sites/default/settings.php grumphp.yml &&
    git commit

    Also note that whenever you update wunderio/ddev-drupal package, you need to add everything under .ddev to GIT.

  2. Import database:

    ddev import-db --file=some-sql-or-sql.gz.file.sql.gz

    or install site:

    ddev drush si
  3. Create admin link and login:

    ddev drush uli

Performance Optimization

Database Operations for Mac Users

Important for Mac users: When working with database imports and exports on macOS, you should store your database dump files in the database_dumps directory at the project root. This directory is specially configured in this template to provide specific performance benefits.

project-root/
├── database_dumps/    <- Place your .sql or .sql.gz files here
├── web/
├── .ddev/
└── ...

Key benefits:

  1. Faster DDEV startup times: When large database files are stored in the standard project directories, they can significantly slow down DDEV startup as Mutagen indexes and syncs these files. Using the database_dumps directory avoids this overhead.

  2. Reduced virtual disk usage: By excluding database dumps from Mutagen synchronization, your virtual disk requires less space, preventing potential disk space issues.

This optimization is configured via upload_dirs in .ddev/config.wunderio.yaml:

upload_dirs:
  - ../database_dumps

Example usage:

# Save your database dumps to the database_dumps directory
cp ~/Downloads/my-database-backup.sql.gz ./database_dumps/

# Then import using the path relative to your project
ddev import-db --file=database_dumps/my-database-backup.sql.gz

This improvement is particularly noticeable in projects with multiple or large database dumps, where startup times can be reduced from minutes to seconds.

Note for Linux users: While this configuration doesn't provide performance improvements on Linux systems (which don't use Mutagen), it's still good practice to store database dumps in the dedicated database_dumps folder for consistent organization across team environments.

wunderio/ddev-drupal 适用场景与选型建议

wunderio/ddev-drupal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.1k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 wunderio/ddev-drupal 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2023-12-13