How to forget to run php ./vendor/bin/drush cr for ever

How to forget to run php ./vendor/bin/drush cr for ever


Yes, it is possible to automatically run php ./vendor/bin/drush cr on file save, typically by using file-watching tools like nodemon, entr, or IDE-specific plugins (e.g., VS Code "Run on Save"). These tools detect file changes in your Drupal directory and execute the drush command to clear the cache.

  • Using nodemon (Node.js):
    Install nodemon and run:
    nodemon --watch web/modules --watch web/themes --ext php,yml,twig --exec "php ./vendor/bin/drush cr"
  • Using entr (Unix tool):
    find . -name "*.php" -o -name "*.yml" -o -name "*.twig" | entr -p php ./vendor/bin/drush cr
  • IDE Extension (VS Code):
    Install an extension like "Run on Save" and configure it to trigger php ./vendor/bin/drush cr when PHP, YML, or TWIG files are saved.
  • Performance: Automatically clearing cache on every save can slow down development, especially with large projects.
  • Pathing: Ensure you are running the command from the project root or adjust the path to vendor/bin/drush accordingly.
  • PHP Version: If required, specify the PHP version explicitly if your server environment requires a specific version (e.g., php83 ./vendor/bin/drush cr).

Comments

Popular posts from this blog

Открываем порт для сервера Minecraft на роутере mikrotik (команда для терминала в WinBox)

Интересное о Формальдегиде