drush php-evalfor drush 9x

Evaluate arbitrary php code after bootstrapping Drupal (if available).

drush php-eval

  • Aliases

    php-eval has 2 alias/es:

    drush eval

    drush ev

  • Arguments

    php-eval accepts 1 argument/s:

    php* : Code to execute.

  • Options

    php-eval accepts 4 option/s:


    --format : format


    --notify : notify


    --druplicon : druplicon


    --xh-link : xh-link

  • Examples

    Sets the hello variable using Drupal API.

    php-eval 'variable_set("hello", "world");'

    Loads node with nid 1 and then prints its title.

    php-eval '$node = node_load(1); return $node->title;'

    Copies a file whose path is determined by an environment's variable. Note the use of double quotes so the variable $HOME gets replaced by its value.

    php-eval "file_unmanaged_copy('$HOME/Pictures/image.jpg', 'public://image.jpg');"

    Rebuild node access permissions.

    php-eval "node_access_rebuild();"

  • Comments

    comments powered by Disqus