Drupal tools for developers
Let's start with your most used tool!
Two references here:
Nothing beats PHPStorm (opens in a new tab) for a Drupal job. Composer, Git, Docker, Xdebug, Drupal coding standards, web services support, Drupal indentation style and perfect autocompletion with inline documentation.
Also, it has support for many plugins Twig, Symfony, Laravel, Blade, Gitignore, Markdown, ... It's not free, but you can get a free license if you are a student (opens in a new tab) or an open source contributor (opens in a new tab).
- Drupal development using PHPStorm Drupal.org (opens in a new tab) - JetBrains (opens in a new tab)
- Keyboard shortcuts for PHPStorm (opens in a new tab)
It is free and has a lot of plugins, that still need to be configured to get a similar level of integration as PHPStorm.
Drupal comes with great caching for production, but before you start development tasks, there is some configuration to prevent caching.
Displaying the Twig templates used by regions, blocks, nodes, ...
parameters: twig.config: debug: true
Then cache rebuild
It's even simpler with Drupal 10.1.0 Simplifying the frontend developer experience in Drupal with a click of the button (opens in a new tab)
Other Twig techniques are available on the following links from Drupal.org.
- Debugging Twig templates (opens in a new tab)
- Discovering and Inspecting Variables in Twig Templates (opens in a new tab)
- Using attributes in templates (opens in a new tab)
Symfony dumper is available out of the box via
composer require --dev drupal/devel composer require --dev kint-php/kint drush en devel
then configure it in /admin/config/development/devel and use in code
Install XDebug (opens in a new tab)
Drush is a command line shell interface for Drupal. To require it in your project, use Composer. It is advised to require it per project and not globally, so you can use different versions of Drush for different projects.
composer require drush/drush
Then you can use it with
To dig your way out of the list of commands, use grep. E.g.:
drupal list | grep service
Drush can be extended with your own commands, so contributed modules are often providing specific commands.
Here is a short list of most used Drush commands.
drush si -y standard --sites-subdir default --account-name admin --account-pass admin --existing-config
- Cache rebuild
- Cache clear
drush ccthen select which one
- Cache get
drush cg [cid] [bin]or set
drush cs [cid] [bin]
- as user 1
- as another user
drush uli --uid 2or
drush uli [name]
- partially import
drush cim --partial --source=/path/to/module/config/install
- Open SQL CLI
- SQL Query
drush sql:query ["SELECT * FROM users"]
- Sanitize (remove or obfuscate user data)
- Database update
- SQL dump
drush sql:dump --result-file=auto --gzip
- Delete all article nodes
drush entity:delete node --bundle=article
- Sync DB, skip tables
drush sql:sync @self.prod @self --skip-tables-list=redirect_404,cache_*
- rsync files, exclude files
drush rsync @self.prod:%files/ @self:%files/ --exclude-paths=css:js:php/twig
drush php-eval "echo drupal_get_installed_schema_version('my_module');"
- List queues
- Run a queue
drush queue:run [name]
- Filter the logs interactively
The ultimate guide to write tests for Drupal 8 modules, themes and profiles. It aims to provide sample code and methods to write different types of testings available in core.
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /file/to/drupal/example_module
phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /file/to/drupal/example_module
- Drupal coding standards (opens in a new tab)
- Install PHP Code Sniffer (opens in a new tab) and Command line usage (opens in a new tab)
- Configure Code Sniffer under PHPStorm (opens in a new tab)
Review the Developer Experience projects section.
- 2023 Drupal Local Development Survey Results (opens in a new tab) - Ironstar
- A complete list of Development tools overview (opens in a new tab) (Drupal.org)