The other day I was reviewing my read later items and stumbled upon the New command line tool to install & run Drupal change record I had completely forgotten about. This was timely because I was extensively testing the excellent Acquia Developer Studio for work and was trying to think about how it could help me review core changes quickly or contribute more easily. Turns out, you can’t ask for a tool to do everything and sometimes it’s important to get back to finding the right tool for the job. And in this instance,
quick-start has no equivalent that I know of in terms of ease of use and required dependencies.
After playing with it a bit, I realized I could probably create a wrapper to speed up operations even more. The workflow I had in mind was this:
- Work exclusively from the local Drupal Git clone
- Don’t install any dependency like Drush or Drupal Console
- Install Drupal with a one-liner
- Optionally select a different install profile
- Optionally install a patch
- Clean up everything with a one-liner
When I type
quick-start, I can either pass a Drupal profile or use the default (
standard). The script takes care of pulling Composer dependencies and installing Drupal with default parameters so I can concentrate on the task at hand, not the install process itself. At some point I even experimented with assigning a dynamic port (
shuf -i8000-8999 -n1) but that was so over-engineered I gave up. This is how it looks like now:
$ quick-start umami Drupal codebase detected. Proceeding... > Drupal\Core\Composer\Composer::ensureComposerVersion Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 106 installs, 0 updates, 0 removals - Installing composer/installers (v1.7.0): Loading from cache > Drupal\Core\Composer\Composer::vendorTestCodeCleanup (snip) Generating autoload files > Drupal\Core\Composer\Composer::preAutoloadDump > Drupal\Core\Composer\Composer::ensureHtaccess Skipped installation of bin bin/composer for package composer/composer: file not found in package 18/18 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] Congratulations, you installed Drupal! Username: admin Password: UvtRWr-Z82WKfV2Q Drupal development server started: <http://localhost:8888> This server is not meant for production use. One time login url: <http://localhost:8888/en/user/reset/1/1570899448/vVyaEHQkIRKGLLtuRttsdXtCBfNP1DBMWJwQIH4_XKc/login> Press Ctrl-C to quit the Drupal development server.
If I want to, I can even pass a patch file:
$ quick-start minimal https://www.drupal.org/files/issues/2019-09-10/2966607-127.patch Drupal codebase detected. Proceeding... HEAD is now at 10c41e77a5 Issue #3079810 by jhodgdon, andypost, mikelutz: core/help_topics directory does not work Already up to date. --2019-10-15 16:27:51-- https://www.drupal.org/files/issues/2019-09-10/2966607-127.patch Resolving www.drupal.org (www.drupal.org)... 126.96.36.199, 188.8.131.52, 184.108.40.206, ... Connecting to www.drupal.org (www.drupal.org)|220.127.116.11|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 33247 (32K) [text/plain] Saving to: ‘2966607-127.patch’ 2966607-127.patch 100%[===============================================>] 32,47K --.-KB/s in 0,02s 2019-10-15 16:27:51 (1,27 MB/s) - ‘2966607-127.patch’ saved [33247/33247] Checking patch core/lib/Drupal/Core/Cache/CacheTagsChecksumInterface.php... (snip). Applied patch core/tests/Drupal/KernelTests/Core/Cache/EndOfTransactionQueriesTest.php cleanly. > Drupal\Core\Composer\Composer::ensureComposerVersion Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 107 installs, 0 updates, 0 removals - Installing composer/installers (v1.7.0): Loading from cache (snip) 18/18 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] Congratulations, you installed Drupal! Username: admin Password: yIk4BtdbLEtyZ80X Drupal development server started: <http://localhost:8888> This server is not meant for production use. One time login url: <http://localhost:8888/user/reset/1/1571149676/oWK8NQiIUWvOzVqieC-jEfjfpjy0hkINpX4rDAKNOL4/login> Press Ctrl-C to quit the Drupal development server.
The one annoyance I have is this whole solution doesn’t really scale. I understand
quick-start is for dev only and I should keep my expectations low, but it’ll fail randomly when using devel_generate, clicking on too many pages in a short period of time or installing too many modules at once. When this happens to you, just shut down the server (
C^) and run
quick-start again. This is a severe limitation I’ve reported here.
Anyway, once I’m done and want to clean up my repo, there’s the
quick-clean command for that. It’ll wipe everything within your Git clone (seriously, be careful) so you come back to a clean Git state, with the latest commits from upstream. It looks like this:
$ quick-clean Drupal codebase detected. Proceeding... [sudo] password for anavarre: HEAD is now at 03bdf28929 Issue #2860644 by daffie, shashikant_chauhan, dww: Add support of NOT REGEXP operator to PostgreSQL + fix testRegexCondition Already up to date.
To my knowledge, there’s no easiest nor quickest way to install, test or contribute to Drupal with the bare minimum requirements to run a PHP app. Here’s a demo.