Skip to content


Run php a script after a full Drupal bootstrap.

A useful alternative to eval command when your php is lengthy or you can't be bothered to figure out bash quoting. If you plan to share a script with others, consider making a full Drush command instead, since that's more self-documenting. Drush provides commandline options to the script via a variable called $extra.


  • drush php:script example --script-path=/path/to/scripts:/another/path. Run a script named example.php from specified paths
  • drush php:script -. Run PHP code from standard input.
  • drush php:script. List all available scripts.
  • drush php:script foo -- apple --cider. Run foo.php script with argument apple and option cider. Note the -- separator.


  • [extra]....


  • --format[=FORMAT]. [default: var_export]
  • --script-path=SCRIPT-PATH. Additional paths to search for scripts, separated by : (Unix-based systems) or ; (Windows).



  • scr
  • php-script


  • An argument or option with square brackets is optional.
  • Any default value is listed at end of arg/option description.
  • An ellipsis indicates that an argument accepts multiple values separated by a space.