php:cli¶
Open an interactive shell on a Drupal site.
Entity classes are available without their namespace. For example, Node::load(1) works instead of Drupal\Node\entity\Node::load(1). Entity bundles classes are also available without their namespace. For example, NodeArticle::load(1) works instead of Drupal\node_article\entity\NodeArticle::load(1). Also, a loadRevision static method is made available for easier load of revisions.
Help topics:
Examples¶
php:cli $node = Node::load(1)php:cli $node = NodeArticle::load(1)php:cli $paragraph = Paragraph::loadRevision(1)
Options¶
- --version-history. Use command history based on Drupal version. Default is per site.
- --cwd=CWD. A directory to change to before launching the shell. Default is the project root directory
- --format=FORMAT. Format the result data. Available formats: csv,json,list,null,php,print-r,string,table,tsv,var_dump,var_export,xml,yaml [default: null]
- --fields=FIELDS. Limit output to only the listed elements. Name top-level elements by key, e.g. "--fields=name,date", or use dot notation to select a nested element, e.g. "--fields=a.b.c as example".
- --field=FIELD. Select just one field, and force format to string.
Global Options¶
- -v|vv|vvv, --verbose. Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
- -y, --yes. Auto-accept the default for all user prompts. Equivalent to --no-interaction.
- -l, --uri=URI. A base URL for building links and selecting a multi-site. Defaults to https://default.
- To see all global options, run
drush core:global-options.
Aliases¶
- php
- core:cli
- core-cli
Legend
- 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.