The Drupal Watcher script is a handy tool that monitors specified directories for file changes within a Drupal project. It automatically clears the Drupal cache using Drush whenever a file is modified, ensuring your Drupal site remains up-to-date and responsive to changes during development.
-
Move the Script: Place the
drupal_watcher
script in/usr/local/bin
to make it accessible system-wide:mv drupal_watcher /usr/local/bin/drupal_watcher
-
Navigate to Your Drupal Project Directory:
cd /Users/user/Sites/drupal-project
-
Run the Script:
drupal_watcher
- Operating System: macOS
- Package Manager: Homebrew
The script automatically monitors the following directories for file changes:
docroot/modules/custom
docroot/themes/custom
It requires Drush to be installed in the vendor/bin
directory.
You have the flexibility to customize the directories to watch and the actions to perform by directly editing the script variables within the drupal_watcher
file. This customization allows you to tailor the script according to your Drupal project's specific requirements and directory structure.
- Executable Permissions: Before moving the script file (
drupal_watcher
) to/usr/local/bin
, ensure it has executable permissions set:chmod +x drupal_watcher