You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Composer](https://getcomposer.org) came into the PHP world to help with dependency-management—managing the growing network of external libraries that modern applications rely on. If you’re setting up a PHP development environment with Composer for TYPO3 or Drupal 8, DDEV can help make it easier. DDEV now has built-in Composer commands so you don’t have to install Composer on your host machine. You can use Composer right in the container. Overall, our goal with DDEV is to give users ultimate flexibility, yet predictability at the same time.
15
+
[Composer](https://getcomposer.org) came into the PHP world to help with dependency-management—managing the growing network of external libraries that modern applications rely on. If you’re setting up a PHP development environment with Composer for most modern PHP environments, DDEV can help make it easier. DDEV has built-in Composer commands so you don’t have to install Composer (or PHP) on your host machine. You can use Composer right in the container. Overall, our goal with DDEV is to give users ultimate flexibility, yet predictability at the same time.
15
16
16
-
[Download DDEV](https://github.com/ddev/ddev)
17
+
[Get Started With DDEV](/get-started)
17
18
18
19
### Composer for PHP dependency management
19
20
20
21
As web development evolved in the decade after PHP appeared, different web development communities began to share resources, libraries, and tools in true open source fashion. This made building applications faster but posed a new problem. This network of interconnected libraries meant any given web application could have a (potentially large) number of dependencies. What version of which library does this particular project need? How can we keep them updated?
21
22
22
23
Enter Composer, the dependency manager that [took its inspiration](https://getcomposer.org/doc/00-intro.md) from dependency managers like npm. Unlike some others, Composer works on a per-project basis, pulling in the correct version of the correct libraries from repositories like Packagist, [the main Composer repository](https://getcomposer.org/doc/01-basic-usage.md#packagist).
23
24
24
-
Composer is the recommended way to develop for both TYPO3 CMS and Drupal 8, but it still causes issues, particularly for Windows users. Now with DDEV’s support for Composer, you don’t even have to install Composer on your local machine. You’ll get a more predictable experience and have one less thing to worry about.
25
-
26
-
## Composer and DDEV are better together
27
-
28
-
Before the DDEV 1.4 release, our instructions were written assuming the typical user was a Mac or Linux user with Composer installed. It didn’t work well for lots of Windows users. The fundamental “gotcha” that proved most challenging for Windows users was that even if they get PHP and Composer set up properly on their Windows machine, they still ran into trouble when they ran the `composer create-project` command.
29
-
30
-
We noticed more and more of our Windows users sharing workarounds [in our community](https://docs.ddev.com/en/stable/users/support/), such as Slack and [Stack Overflow](https://stackoverflow.com/questions/tagged/ddev). We realized how we could make this a lot easier, and in DDEV 1.4, we released several improvements to make the experience better, particularly for Windows users.
31
-
32
-
The new Composer command in DDEV simplifies the use of Composer, and allows you to create and manage projects without having Composer installed on your host machine.
33
-
34
-
As a bonus, we also changed Composer cache; now it resides in a shared Docker volume, making it much faster to do in-container Composer builds.
25
+
Composer is the recommended way to develop for many PHP frameworks and CMSs, but it still can cause issues, particularly for Windows users. Now with DDEV’s support for Composer, you don’t even have to install Composer on your local machine. You’ll get a more predictable experience and have one less thing to worry about.
35
26
36
27
## Built-in Composer commands in DDEV
37
28
38
-
The new `ddev composer` feature is a wrapper on Composer that does everything inside the container, eliminating the need to install Composer on the host. If you’ve used Composer before, it will seem pretty familiar, but there’s an important difference to note.
29
+
The `ddev composer` feature is a wrapper on Composer that does everything inside the container, eliminating the need to install Composer on the host. If you’ve used Composer before, it will seem pretty familiar, but there’s an important difference to note.
39
30
40
-
Our recommended [quickstart](https://docs.ddev.com/en/stable/users/quickstart/) techniques for both [TYPO3 CMS](https://docs.ddev.com/en/stable/users/quickstart/#typo3) and [Drupal 8](https://docs.ddev.com/en/stable/users/quickstart/#drupal) use Composer to create projects. You can also check out the docs on using the command line interface for [ddev and Composer](https://docs.ddev.com/en/stable/users/developer-tools/#ddev-and-composer).
31
+
Our recommended [quickstart](https://docs.ddev.com/en/stable/users/quickstart/) techniques for [TYPO3 CMS](https://docs.ddev.com/en/stable/users/quickstart/#typo3) and [Drupal](https://docs.ddev.com/en/stable/users/quickstart/#drupal) use Composer to create projects. You can also check out the docs on using the command line interface for [ddev and Composer](https://docs.ddev.com/en/stable/users/usage/developer-tools/#ddev-and-composer).
41
32
42
33
Most of the Composer features in the command line ddev app are direct analogs of Composer usage. You can prepend a Composer command with `ddev` and it works the same as the [commands in Composer](https://getcomposer.org/doc/03-cli.md). That includes
43
34
44
35
-`ddev composer require`
45
36
-`ddev composer install`
46
37
-`ddev composer update`
38
+
-`ddev composer create-project`
47
39
- And so forth!
48
40
49
-
The one thing that’s different is the command to create a project. If you’re familiar with Composer already, you know the [command to create a project](https://getcomposer.org/doc/03-cli.md#create-project) is this:
50
-
51
-
`composer create-project`
41
+
The one thing that’s different is `ddev composer create-project`. If you’re familiar with Composer already, you know the [command to create a project](https://getcomposer.org/doc/03-cli.md#create-project) is this:
52
42
53
-
In ddev, you run this command: `ddev composer create`. For example, our [TYPO3 quickstart](https://docs.ddev.com/en/stable/users/quickstart/#typo3) recommends you run this command:
In DDEV, you use `ddev composer create-project <name>` without the additional directory component (all installs are done in the current [composer_root](https://docs.ddev.com/en/stable/users/configuration/config/#composer_root), which is the project root by default). For example, our [TYPO3 quickstart](https://docs.ddev.com/en/stable/users/quickstart/#typo3) recommends you run this command:
56
48
57
-
The standard Composer command requires that you are creating a project in a completely empty directory. With ddev that’s not possible, we have a .ddev directory already, if nothing else. So what ddev does in the background is to create the project in a temporary directory, then it copies back into the project root. From the command line interface, you won’t even notice it.
In fact, if you do attempt to run `ddev composer create-project` you’ll get a friendly reminder that this command is unsupported, and ddev will tell you to use `ddev composer create` for basic project creation.
53
+
The standard Composer command requires that you are creating a project in a completely empty directory. With DDEV that’s not possible, we have a `.ddev` directory already, if nothing else. So what DDEV does in the background is to create the project in a temporary directory, then it copies back into the project root. From the command line interface, you won’t even notice it.
60
54
61
-
Another thing you can do is execute Composer in other directories within the container. [SSH into a container](https://docs.ddev.com/en/stable/users/cli-usage/#ssh-into-containers) to open an interactive Bash shell session to the container. Then you can use Composer ‘natively’ ([see the docs](https://docs.ddev.com/en/stable/users/developer-tools/#ddev-and-composer)). You can end the native Composer session by typing `exit`.
55
+
Another thing you can do is execute Composer in other directories within the container. [SSH into a container](https://docs.ddev.com/en/stable/users/cli-usage/#ssh-into-containers) to open an interactive Bash shell session to the container. Then you can use Composer directly inside the container ([see the docs](https://docs.ddev.com/en/stable/users/usage/developer-tools/#ddev-and-composer)). You can end the Composer session by typing `exit`.
62
56
63
-
As the [documentation on ddev and Composer explains](https://docs.ddev.com/en/stable/users/developer-tools/#ddev-and-composer), ddev will execute the Composer command at the project root in the web container, passing all arguments and flags to Composer, as the examples here show.
57
+
As the [documentation on ddev and Composer explains](https://docs.ddev.com/en/stable/users/usage/developer-tools/#ddev-and-composer), DDEV will execute the Composer command at the project root (the path can be changed with the [composer_root](https://docs.ddev.com/en/stable/users/configuration/config/#composer_root) option) in the web container, passing all arguments and flags to Composer, as the examples here show.
64
58
65
-
`ddev composer createdrupal-composer/drupal-project:8.x-dev --stability dev --no-interaction`
59
+
`ddev composer create-project "drupal/recommended-project:^11" --stability dev --no-interaction`
Each of these examples shows that the Composer commands will work, passing all options to Composer.
74
68
75
69
## Get started with DDEV and Composer
76
70
77
-
Composer is a great solution for dependency management in PHP, but it’s still not consistently applied across operating systems. Reduce friction in your development workflows by setting up consistent versions of Composer and PHP on your local development environment and your host with DDEV, our containerized Docker-based dev-to-deploy solution.
71
+
Composer is a great solution for dependency management in PHP, but it’s still not consistently applied across operating systems. Reduce friction in your development workflows by setting up consistent versions of Composer and PHP on your local development and deployment environments.
78
72
79
-
You can use DDEV with any PHP CMS or framework. We test DDEV on—and offer [Quickstart guides](https://docs.ddev.com/en/stable/users/quickstart/) for— Drupal, WordPress, TYPO3 CMS, and Backdrop CMS. Composer is the recommended way to develop with TYPO3 CMS and Drupal.
73
+
You can use DDEV with any PHP CMS or framework. We test DDEV on—and offer [Quickstart guides](https://docs.ddev.com/en/stable/users/quickstart/) for— Drupal, WordPress, TYPO3 CMS, Backdrop CMS and many others. Composer is the recommended way to develop with most of them, including TYPO3 CMS and Drupal.
80
74
81
75
Also, check out these articles:
82
76
83
-
- How to set up a [Docker-based development environment on macOS](watch-ddev-local-from-scratch-with-macos.md).
77
+
-[Watch: DDEV from scratch with Windows WSL2](watch-ddev-local-from-scratch-with-windows-wsl2.md)
78
+
-[DDEV on Linux in 10 Minutes](ddev-on-linux-in-10-minutes.md)
79
+
-[Watch: DDEV From Scratch with macOS](watch-ddev-local-from-scratch-with-macos.md)
84
80
-[Debugging Docker on Windows, Mac, and Linux](debugging-docker-on-windows-mac-and-linux.md)
0 commit comments