For as long as most people have used Drupal, the command line has meant Drush. Drupal core has had a small script of its own for years, core/scripts/drupal, but it was limited to a few developer tasks: installing a test site, starting a web server, applying a recipe and generating a theme. In Drupal 12 that script is deprecated and replaced by dr, a command-line tool in core with a growing set of everyday commands. It is especially useful right now, because Drush has no stable release that works with Drupal 12 yet.
Where it is
Core declares the script as a Composer binary, so in a normal project it is at:
vendor/bin/dr
Run it from the project root. The old core/scripts/drupal still works but prints a deprecation notice: it was deprecated in Drupal 11.4 and will be removed in Drupal 13 (change record 3584928).
The commands
This is what vendor/bin/dr list shows in Drupal 12.0.0-rc1:
| Command | Aliases | What it does |
|---|---|---|
install | Installs Drupal from a profile or a recipe (into SQLite). | |
quick-start | Installs a site and starts a web server for local testing. | |
server | Starts a web server for an existing site. | |
recipe:apply | recipe | Applies a recipe to the site. |
recipe:info | Shows a recipe's description and inputs. | |
ex:install | pm:install, en and more | Installs modules or themes. |
cache:rebuild | cr | Rebuilds all caches. |
system:cron | cron | Runs cron. |
system:status | status | Shows the Drupal and PHP version and the themes in use. |
user:login | uli | Creates a one-time login link. |
content:export | Exports content entities as YAML. | |
generate-theme | Creates a new theme from a starterkit. |
The aliases are deliberate: dr cr, dr uli and dr en work the way Drush users expect.
Examples
# What am I running?
vendor/bin/dr status
# Clear caches after a code change
vendor/bin/dr cr
# Turn on a module
vendor/bin/dr en media
# Apply a core recipe
vendor/bin/dr recipe core/recipes/image_media_type
# Log in as the admin without a password
vendor/bin/dr uli
Exporting content
content:export writes an entity – a node, a term, a media item – as YAML in the format that recipes use for their content folder. That makes it the bridge between a site and a recipe: build a page on a site, export it, and ship it with a recipe.
vendor/bin/dr content:export node 42
vendor/bin/dr content:export node 3 --with-dependencies --dir=content
vendor/bin/dr content:export taxonomy_term --bundle=tags --dir=terms
With --with-dependencies, everything the entity refers to (its author, its terms, its media) is exported too.
What dr cannot do (yet)
In the release candidate, dr has no commands for configuration import and export, database updates, SQL, or watching the log. For a real deployment you still need Drush's config:import, updatedb and deploy – which today means Drush 14.x-dev, see How to install Drupal 12 with Composer. The install command also only installs into SQLite, so it is for local test sites, not for a site on MariaDB, MySQL or PostgreSQL.
Treat dr as the tool that is always there: it comes with core, it matches your core version, and it covers the commands you type ten times a day.