Skip to content

Commit 22e5969

Browse files
rfayclaudestasadev
authored
Update old composer blog (#449)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Stanislav Zhuk <stasadev@gmail.com>
1 parent 088ed6b commit 22e5969

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed
Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
title: "Getting started with DDEV and Composer"
33
pubDate: 2018-11-29
4-
summary: Using DDEV v1.4’s bundled Composer.
4+
modifiedDate: 2025-10-14
5+
summary: Using DDEV's bundled Composer.
56
author: Randy Fay
67
featureImage:
78
src: /img/blog/2018/11/marius-masalar-410695-unsplash-e1543521725507.jpg
@@ -11,74 +12,69 @@ categories:
1112
- Guides
1213
---
1314

14-
[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.
1516

16-
[Download DDEV](https://github.com/ddev/ddev)
17+
[Get Started With DDEV](/get-started)
1718

1819
### Composer for PHP dependency management
1920

2021
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?
2122

2223
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).
2324

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.
3526

3627
## Built-in Composer commands in DDEV
3728

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.
3930

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).
4132

4233
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
4334

4435
- `ddev composer require`
4536
- `ddev composer install`
4637
- `ddev composer update`
38+
- `ddev composer create-project`
4739
- And so forth!
4840

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:
5242

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:
43+
```
44+
composer create-project <name> <directory> <version>
45+
```
5446

55-
`ddev composer create typo3/cms-base-distribution ^9`
47+
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:
5648

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.
49+
```bash
50+
ddev composer create-project "typo3/cms-base-distribution"
51+
```
5852

59-
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.
6054

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`.
6256

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.
6458

65-
`ddev composer create drupal-composer/drupal-project:8.x-dev --stability dev --no-interaction`
59+
`ddev composer create-project "drupal/recommended-project:^11" --stability dev --no-interaction`
6660

67-
`ddev composer create typo3/cms-base-distribution ^9`
61+
`ddev composer create-project "typo3/cms-base-distribution" . "^12"`
6862

6963
`ddev composer require monolog/monolog`
7064

71-
`ddev composer update --with-dependencies`
65+
`ddev composer update --with-all-dependencies`
7266

7367
Each of these examples shows that the Composer commands will work, passing all options to Composer.
7468

7569
## Get started with DDEV and Composer
7670

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.
7872

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.
8074

8175
Also, check out these articles:
8276

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)
8480
- [Debugging Docker on Windows, Mac, and Linux](debugging-docker-on-windows-mac-and-linux.md)

0 commit comments

Comments
 (0)