The days of XAMPP and MAMP are over. Modern PHP development requires reproducible environments that closely mirror the production server. Docker is ideal for this -- and DDEV makes it comfortable.
Why DDEV?
DDEV abstracts away the complexity of Docker and offers a specialized solution for PHP projects. The advantages:
- Quick setup -- A single
ddev configandddev startis all it takes - Pre-configured -- PHP, MariaDB/MySQL, Nginx, Mailpit, phpMyAdmin
- Multiple projects -- Each project gets its own isolated environment
- SSL out of the box -- Automatic HTTPS certificates
Project Configuration
A typical .ddev/config.yaml looks like this:
name: mein-projekt
type: symfony
docroot: public
php_version: "8.2"
mariadb_version: "10.11"
webserver_type: nginx-fpm
timezone: Europe/Berlin
additional_hostnames:
- mein-projekt.local
Useful DDEV Commands
These are the commands I use most frequently in my daily work:
# Projekt starten und stoppen
ddev start
ddev stop
# In den Container springen
ddev ssh
# Composer und Node.js
ddev exec composer install
ddev exec npm run build
# Datenbank-Import
ddev import-db --file=dump.sql.gz
# Logs anzeigen
ddev logs -f
Custom Commands
DDEV can be extended with custom commands. A file placed under .ddev/commands/web/ automatically becomes available as a command:
#!/bin/bash
## Description: Run PHPUnit tests
## Usage: phpunit
## Example: ddev phpunit
vendor/bin/phpunit "$@"
After that, you can simply run tests with ddev phpunit.
Team Collaboration
The greatest advantage of DDEV becomes apparent in a team setting: every developer has exactly the same environment. No more "it works on my machine" discussions. The .ddev/ configuration belongs in the Git repository, and new team members are up and running in just a few minutes.
DDEV has significantly simplified my development workflow. Anyone still struggling with local PHP installations should definitely consider making the switch.
Kommentare
Kommentare werden von Remark42 bereitgestellt. Beim Laden werden Daten an unseren Kommentar-Server übertragen.