Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Fox drush console

Security covered Drupal 10–11
View on drupal.org

Fox is a command-line tool that allows you to manage Drupal entities using a query language similar to SQL. You can use it to select, create, update, and delete content, and even perform bulk operations and automate tasks.

Fox is a declarative REPL for Drush. Manage Drupal entities using a concise query language (FoxPro/SQL syntax): queries, FOR loops, and bulk REPLACE and DELETE operations on the fly.

The module adds drush command: fox:console (fox). Command allow you to obtain data at entity (context) levels. Context: entity_type.bundle .

The module can be useful during audits, migrations, developing, CI/CD and architecture reviews. May also be useful for CLI tools such as Pantheon hosting's terminus.

Key Features

  • Context-driven approach: Select an entity type and bundle via USE node.page and work within that context.
  • Custom query language (Fox Entity Query): A powerful SELECT ... FROM ... WHERE ... INTO ... syntax for retrieving data without writing PHP code.
  • Batch processing and loops (Mass Updates with FOR): Support for iterating over result arrays using the FOR @variable construct. You can perform bulk operations (REPLACE, DELETE) by automatically iterating through rows of data.
  • Data mutations "on the fly": The CREATE, APPEND, REPLACE and DELETE commands modify data gently and safely via the standard Drupal Entity API.
  • Support for internal variables: SET, IF ... THEN constructs and system iterators (e.g. @__index for the current index in a loop or @count) allow you to write flexible automation scripts.
  • Native SQL and external calls: Execute native SQL (via SQL ...) and run external Drush commands directly within a session (DRUSH ...).
  • Support languages (--langcode option for some commands)
  • Command automation: You can easily extend Fox by generating custom commands via drush gen fox:command.

Fox console has condition approach:
IF condition THEN command1&command2&... ELSE command3&command4&... .

The module uses variables that can be retrieved from the Fox Entity Query or using the SET command. A variable can be evaluated using the '@' symbol. Object field can be evaluated using the '.' symbol, e.g. @data.0.title.

Usage examples:

    • # Block user with uid = 1
    • SELECT status FROM user WHERE uid = 1 INTO data
    • IF @data.0.status = 1 THEN REPLACE status WITH 0
    • # Create taxonomy vocabulary and taxonomy term
    • USE taxonomy_vocabulary
    • SELECT vid WHERE vid = test
    • IF @count <> 0 THEN QUIT
    • APPEND vid WITH test, name WITH Test, description WITH Test taxonomy, status WITH 1, weight WITH 0
    • USE taxonomy_term.test
    • APPEND name WITH test tags, description WITH Test tag, status WITH 1, weight WITH 0
    • PRINT Terms were created (count = @count)
    • # Delete orphaned nodes
    • SQL UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH)) AS last_month INTO data
    • PRINT Month ago timestamp: @data.0.last_month
    • SELECT nid FROM node WHERE status = 0 AND changed < @data.0.last_month INTO nodes
    • DELETE FOR @nodes
    • # Replace a field by another field
    • USE node.page
    • SELECT nid,title INTO data
    • IF @count = 0 THEN QUIT
    • REPLACE field_title2 WITH @data.@__index.title FOR @data

... more examples available in the README.md file

Parameters:

  • --input
    Input commands: "command1;command2" or load file
  • --output
    Output command history to screen or to file
  • --mode
    Command mode: [default]|debug
  • --quit
    Non-interactive mode

Entity query:

  • SELECT fields FROM context WHERE conditions ORDER BY order LIMIT limit OFFSET offset INTO variable
  • SET active TO 1; FROM user WHERE status = @active

Fox commands:

Navigation

  • USE
    Select context, for example node.page (node entity type, page bundle).
    Usage: USE [context]. USE without context cleared existing context.
  • GO
    Set context record.
    Usage: GO {TOP|BOTTOM|PREV [number]|NEXT [number]|number}
  • SEEK
    Seek context record by entity ID.
    Usage: SEEK <id>
  • BROWSE
    Browse fields for context record.
    Usage: BROWSE [*|fields] [--langcode={langcode} --vertical --json].

Mutations

  • CREATE
    Create record.
    Usage: CREATE <id> [, label]
  • APPEND
    Append record with fields.
    Usage: APPEND uField1 [WITH eExpr1 [, uField2 WITH eExpr2]] [--langcode={langcode}]
  • CLONE
    Clone context record.
    Usage: CLONE [id, label]
  • REPLACE
    Replace fields for context record. Supports inner index variable @__index for FOR option.
    Usage: REPLACE uField1 WITH eExpr1 [, uField2 WITH eExpr2, ...] [FOR @variable] [--langcode={langcode}]
  • DELETE
    Delete context record.
    Usage: DELETE [FOR @variable] [--langcode={langcode}]

Variables

  • SET
    Set variables.
    Usage: SET <var1 TO eExpr1> [, var2 TO eExpr2, ...]
    Delete variable: SET var1 TO
  • PRINT
    Print variable.
    Usage:PRINT <variable> [,variable2, ...] [TYPE {SUCCESS|WARNING|ERROR|INFO}]
  • TEST
    Test variables.
    Usage: TEST <function> <variable> <operand> <value> [message].
    Functions: COUNT, STRING.

Loading

  • LOAD
    Load file with fox commands.
    Usage: LOAD <filename>
  • DRUSH
    Call an external Drush command.
    Usage: DRUSH <command> [JSON args] [--JSON options] [INTO variable]

Information

  • STATUS
    Fox status.
    Usage: STATUS [--vertical]
  • INFO
    List entities,bundles or fields list for entity,bundle.
    Usage: INFO [entity_id.[bundle]]
  • LIST
    List Fox commands.
    Usage: LIST
  • SQL
    Execute native SELECT|SHOW|DESCRIBE SQL.
    Usage: SQL <expression> [,expression2, ...] [INTO variable]
  • FILE
    Get file information.
    Usage: FILE <uri> [INTO variable]

Similar projects:

Sponsorship

...have a feature you'd like to sponsor? Get in touch

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
33
Tracked since
Nov 2024
Latest release
3 weeks ago
Releases (12 mo)
18 ▲ from 15
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.6.2 Stable 10–11 Aug 7, 2026
1.6.1 Stable 10–11 Aug 4, 2026
1.6.0 Stable 10–11 Jun 26, 2026
1.5.7 Stable 10–11 Jun 10, 2026
1.5.6 Stable 10–11 Jun 3, 2026
1.5.5 Stable 10–11 May 21, 2026
1.5.4 Stable 10–11 Apr 27, 2026
1.5.3 Stable 10–11 Apr 16, 2026
1.5.2 Stable 10–11 Apr 3, 2026
1.5.1 Stable 10–11 Apr 1, 2026
1.5.0 Stable 10–11 Mar 29, 2026
1.4.11 Stable 10–11 Mar 26, 2026
1.4.10 Stable 10–11 Mar 22, 2026
1.4.9 Stable 10–11 Mar 14, 2026
1.4.8 Stable 10–11 Oct 4, 2025
1.4.7 Stable 10–11 Sep 21, 2025
1.0.x-dev Dev 10–11 Sep 11, 2025
1.4.6 Stable 10–11 Sep 11, 2025
1.4.5 Stable 10–11 Jul 29, 2025
1.4.4 Stable 10–11 Jul 23, 2025
1.4.3 Stable 10–11 May 3, 2025
1.4.2 Stable 10–11 Apr 29, 2025
1.4.1 Stable 10–11 Apr 24, 2025
1.4.0 Stable 10–11 Apr 24, 2025
1.3.6 Stable 10–11 Apr 19, 2025
1.3.5 Stable 10–11 Apr 13, 2025
1.3.4 Stable 10–11 Apr 3, 2025
1.3.3 Stable 10–11 Mar 23, 2025
1.3.2 Stable 10–11 Feb 16, 2025
1.3.1 Stable 10–11 Feb 13, 2025
1.3.0 Stable 10–11 Feb 3, 2025
1.2.0 Stable 10–11 Jan 5, 2025
1.1.4 Stable 10–11 Nov 14, 2024