Score:5

Does the built-in PHP web server have disadvantages over other local development alternatives?

br flag

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?

leymannx avatar
ne flag
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.
Kevin avatar
in flag
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.
Score:8
cn flag

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.

apaderno avatar
us flag
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.
Christoph Burschka avatar
cn flag
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.
Score:3
us flag

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"

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.