5

When watching Install Drupal for Local Development, I leant that Drupal 8 and Drupal 9 come with a built-in PHP web server that can be set up quickly by cloning the core and running php -S localhost:8000. However, the official Local Development Guide does not mention this and instead advises to use DDEV for local development.

If the built-in PHP web server is so quick to set up, why should I be using DDEV or any other alternatives for local development (e.g., WAMP/MAMP/XAMPP, Docker, Acquia's Cloud IDEs, etc.)? Do these alternatives have features that the built-in PHP web server does not, for example?

2
  • 1
    You could wear just shoes to walk on and go outside. Why do you need all the other clothes for just walking? DDEV (and to some extend the other listed alternatives as well) takes care of much more than just providing a server to run Drupal on. It comes with SSL, Drush, Databases, Composer and many many more. It is configurable, extendable, deployable among your colleagues, mimics the production server Drupal will later run on publicly and so on. You'll always need more than just a bare-naked PHP server to run Drupal with ease.
    – leymannx
    Feb 6, 2022 at 16:24
  • A php webserver simply offers no advantage. It's nowhere near what a real environment would be like and every feature you will want to add will be a complete hassle. Just use Docker.
    – Kevin
    Feb 6, 2022 at 16:44

2 Answers 2

8

Drupal 8 and 9 do not come with a built-in webserver.

php -S is PHP's bare bones webserver for limited testing. Read more in the PHP manual.

The PHP built-in server is not good for local development because you want your local development environment to match your production/live environment as much as possible, so it's good to run the same server locally that you use in production.

DDEV, lando, and other docker-based local dev solutions will let you closely simulate your actual webserver and catch problems before you push your code to the production server.

Also, the PHP built-in server has this specific problem:

The web server runs only one single-threaded process, so PHP applications will stall if a request is blocked.

Basically all webservers the world over are multithreaded, but the PHP built-in server is so bare bones it will choke if you do anything complicated.

So I wouldn't even try to use the built-in PHP server for anything except the most basic of tests.

2
  • 1
    With PHP 7.4, the built-in web server can be configured to fork multiple workers. Still, it won't give any idea of the issues the site could have on the production server.
    – apaderno
    Feb 7, 2022 at 8:55
  • 2
    Specifically for Drupal, note that the single-threaded limitation will break any web tests you run through the web interface (CLI is fine). PHPunit can't reach the server while the server is already busy running PHPunit. Feb 7, 2022 at 16:24
3

App like DDEV do more than just serve a website. They can also manage the database, and cache services or add helpful commands to quickly backup data.

But by using Docker, they handle these in isolation. I can run PHP 8.0 on my main PC, spin up a dev project using PHP 7.4/MySQL, test a different project in PHP 8.1/Postgres, and fix an urgent support request for a legacy PHP 7.2 app.

Juggling multiple PHP versions, their extensions, and support services becomes as easy as "DDEV start" / "DDEV stop"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.