Skip to content

Latest commit

 

History

History
130 lines (96 loc) · 2.53 KB

File metadata and controls

130 lines (96 loc) · 2.53 KB

DDEV Hooks and Additional Services

Contents

Post-start hooks in detail

Hooks automate repetitive tasks after ddev start.

Hook: Create a test database

hooks:
  post-start:
    - exec-host: ddev mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS db_test; GRANT ALL PRIVILEGES ON db_test.* TO 'db'@'%'; FLUSH PRIVILEGES;"

Hook: Clear the Thelia cache

hooks:
  post-start:
    - exec: php Thelia cache:clear

Hook: Install dependencies

hooks:
  post-start:
    - composer: install  # Shorthand for ddev composer install

Hook: Compile assets

The two theme families do not share a toolchain: the Flexy front office runs on AssetMapper plus the Tailwind CLI binary and has no package.json, while the default-twig back office is still a Webpack Encore theme.

hooks:
  post-start:
    - exec: php bin/console importmap:install
    - exec: php bin/console tailwind:build
    - exec: bash -c "cd templates/backOffice/default-twig && npm install && npm run build"

Hook: Start Messenger

hooks:
  post-start:
    - exec: symfony run --daemon bin/console messenger:consume async -vv

Note: exec commands run inside the web container. exec-host commands run on the host machine.

Mailpit (email testing)

DDEV includes Mailpit to capture outgoing emails.

Configuration

# .env.local
MAILER_DSN=smtp://localhost:1025

Web interface

https://project-name.ddev.site:8026

All emails sent by the application are captured and visible in Mailpit.

Multi-container services

Adding a service (Redis, Elasticsearch, etc.)

# .ddev/docker-compose.redis.yaml
version: '3.6'
services:
  redis:
    image: redis:7-alpine
    container_name: ddev-${DDEV_SITENAME}-redis
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.approot: $DDEV_APPROOT
    volumes:
      - redis-data:/data
    restart: unless-stopped

volumes:
  redis-data:

Usage:

# .env.local
REDIS_URL=redis://redis:6379
# Test the connection
ddev exec redis-cli -h redis ping

PHP customization

Custom php.ini

; .ddev/php/custom.ini
memory_limit = 512M
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 300

Restart after any modification:

ddev restart