DDEV
DDEV is an open source tool for launching local PHP development environments in minutes.
DDEV creates a config.yaml, this contains all settings for your project. This can be versioned in GIT and supports collaborative work in teams or freelancers.
Info
To use the DDEV, Docker must be installed on your system. If this is not yet the case, you can download the DDEV documentation for more information about installing these programs.
Install DDEV
DDEV is available for all platforms, please refer to the DDEV documentation for the installation of your platform.
Create project
Tip
The Contao demo website is maintained for the currently supported Contao versions and can be optionally installed. Via the Contao Manager you can simply select this option during the first installation.
Open the console of your choice, create the desired directory and then change to it. The directory name reflects the subsequent project hostname. However, you can configure this additionally.
mkdir contao && cd contaoCreate the DDEV configuration with:
ddev config --project-type=php --docroot=public --webserver-type=apache-fpm --php-version=8.2Install Contao 5.6:
ddev composer create-project contao/managed-edition:5.6After installation, the database credentials must be entered in the .env.local. At the same time, we also set up
Mailpit directly.
ddev dotenv set .env.local --database-url=mysql://db:db@db:3306/db --mailer-dsn=smtp://localhost:1025Then create the database:
ddev exec contao-console contao:migrate --no-interactionCreate backend user (Administrator):
ddev exec contao-console contao:user:create --username=admin --name=Administrator --email=admin@example.com --language=en --adminCall up the Administration in the browser:
ddev launch contaoOpen the console of your choice, create the desired directory and then change to it. The directory name reflects the subsequent project hostname. However, you can configure this additionally.
mkdir contao && cd contaoCreate the DDEV configuration with:
ddev config --project-type=php --docroot=public --webserver-type=apache-fpm --php-version=8.2After installation, the database access data must be entered in the .env.local. At the same time, we also set up Mailpit directly.
ddev dotenv set .env.local --database-url=mysql://db:db@db:3306/db --mailer-dsn=smtp://localhost:1025Download the Contao Manager, rename it (.php) and copy it into the public directory. You can also use wget or curl to do this.
ddev start
ddev exec "wget -O public/contao-manager.phar.php https://download.contao.org/contao-manager/stable/contao-manager.phar"Open the Contao Manager and follow the instructions:
ddev launch contao-manager.phar.phpAdditional information
You can find more information about managing projects here.
ddev startstarts the project,ddev stopends it. Make sure beforehand that you have changed to the project folder.ddev poweroffcan stop all started projects/containers from any directory.With
ddev sshyou can switch to the shell of the container and work on the console. Theddevbinary is not available in the container, so first switch to the host console withexit.ddev describegives an overview of the services available in the project and how to access them.ddev xdebug onstarts XDebug. Information about the IDE setup
Info
If you are a Windows user using the “Git Bash” as a console, it may be necessary, depending on your “Git for Windows” configuration, to prepend the command winpty (e.g.: winpty ddev ssh).
Custom PHP Configuration
DDEV can be used to provide additional PHP configurations for a project. You can add any number of .ini files in the directory .ddev/php/. Subsequent changes require a ddev restart. Further information can be found in the DDEV documentation.
An example file in .ddev/php/my-php.ini could look like this:
[PHP]
memory_limit = -1Database Tools
If you want to use a database client such as Adminer or phpMyAdmin for example, you can install these as a
Addon.
Example: Adminer
ddev add-on get ddev/ddev-adminer && ddev restartExample: phpMyAdmin
ddev add-on get ddev/ddev-phpmyadmin && ddev restartWith ddev describe you can find out how to access the respective database tool.
Setting up a cron job in DDEV
since 5.5 The back end search can be activated by setting up the Contao cronjob framework.
To do this, first install the cron add-on in DDEV:
ddev add-on get ddev/ddev-cronInfo
If you have been using DDEV for a long time, you may receive an error message when setting up ddev add-on get ddev/ddev-cron. The reason for this is that the add-on has only been supported by DDEV since version 1.24. So you need to update DDEV. For updates, see https://docs.ddev.com/en/stable/users/install/ddev-upgrade/.
Then create a /.ddev/web-build/contao.cron file with the following content:
* * * * * php /var/www/html/vendor/bin/contao-console contao:cronThen restart the DDEV project/container:
ddev restartThe Contao cronjob is executed every minute. When setting up for the first time, it may take 1-2 minutes before the search bar is available in the back end.
Setting up a local shared repository path inside your DDEV container
If you want to configure a path in your container where all your local bundles are stored and which you can use in your composer.json, you can do so as follows:
Create a file inside the ./ddev folder with the name docker-compose.bundles.yaml.
The content can look like this (Please adjust the paths to suit your needs.):
services:
web:
volumes:
- /home/$USER/repository:/home/$USER/repository:rwThen restart the container with ddev restart.
Now you can use the repository in your root composer.json.
"repositories": [
{
"type": "path",
"url": "~/repository/my-local-bundle"
}
],Info
If the Contao Manager cannot find the repositories, it helps to deactivate the Composer Resolver Cloud.