PHPackages                             drush/example-drush-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. drush/example-drush-extension

ActiveDrupal-drush[CLI &amp; Console](/categories/cli)

drush/example-drush-extension
=============================

Example Drush site-wide extension

1.1.0(6y ago)8571[1 issues](https://github.com/drush-ops/example-drush-extension/issues)[1 PRs](https://github.com/drush-ops/example-drush-extension/pulls)GPL-2.0-or-laterPHPPHP &gt;=5.6CI failing

Since Mar 26Pushed 4y ago4 watchersCompare

[ Source](https://github.com/drush-ops/example-drush-extension)[ Packagist](https://packagist.org/packages/drush/example-drush-extension)[ RSS](/packages/drush-example-drush-extension/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (12)Versions (10)Used By (0)

Example Drush Extension
=======================

[](#example-drush-extension)

[![Build Status](https://camo.githubusercontent.com/3ada19f9218917f06ca4437b03e970042ac4f98972f006c82d0ea976c52efd86/68747470733a2f2f7472617669732d63692e6f72672f64727573682d6f70732f6578616d706c652d64727573682d657874656e73696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/drush-ops/example-drush-extension)

This is an example Drush extension that is compatible with both Drush 9.6+ and Drush 8.2+. It includes tests that run on both versions of Drush.

This this project demonstrates what is known as a "site-wide" Drush extension. Site-wide extensions are installed via Composer into a particular Drupal site. The other kinds of Drush extensions are Drush module commands and Drush global commands. See the [Creating Custom Drush Commands documentation](http://docs.drush.org/en/master/commands/) for more information.

For maximum compatibility with future versions of Drush, a site-wide Drush extension should only call the following APIs:

- APIs provided by Drupal
- APIs provided by Drupal's dependencies
- Libraries decleared in the site-wide extension's own composer.json file

Avoid using Drush APIs, save for those that are defined by your command's base class, [DrushCommands](https://github.com/drush-ops/drush/blob/master/src/Commands/DrushCommands.php), or those that are provided by objects injected into your command class by Drush. See [ExampleCommands.php](ExampleCommands.php) for examples.

Usage
-----

[](#usage)

In development, clone this repository, then set up the System Under Test (sut) via:

```
composer install
composer drupal:scaffold

```

That will set up your local project to run and test with Drush 9. To use Drush 8 instead:

```
composer scenario drush8

```

The [Composer Test Scenarios](https://github.com/g1a/composer-test-scenarios) project is used to manage the Composer dependencies needed to test different scenarios of this project. Running `composer scenario` is like running `composer install`; it will install the appropriate dependencies for the requested testing scenario. Run `composer install` to return to the default installation.

To use this extension in production (that is, to install it in a Drupal 8 site):

```
cd /path/to/my-drupal-composer-drupal-project
composer require drush/example-drush-extension

```

Running Tests
-------------

[](#running-tests)

Set up for 'development' as described in usage section. Then, run:

```
composer test

```

Ad-hoc Testing
--------------

[](#ad-hoc-testing)

In development:

```
composer drush example:param test

```

In production:

```
cd /path/to/my-drupal-composer-drupal-project
drush example:param test

```

Customizing
-----------

[](#customizing)

1. Fork this repository.
2. Alter "name", "description" and etc. in composer.json to suit.
3. Rename ExampleCommands.php and ExampleCommandsTest.php for your project.
4. Configuration and site aliases for use in testing can be placed in 'sut/drush/drush.yml' and 'sut/drush/sites/self.site.yml', respectively.
5. Examine 'sut/drush/drush.yml' and 'sut/drush/drushrc.php', and alter the names of the example command files to match the names in your project. This is necessary for Drush to be able to find your command files when running tests or doing ad-hoc testing, as usually, command files are searched for in the parent directory of the project root.
6. Add your extension on packagist.org so that it may be installed via Composer.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~92 days

Total

3

Last Release

2419d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b34cc6bd882277b6c6dda19bf6631ae5c3a909fd667c826a15121642cdc051b2?d=identicon)[greg.1.anderson](/maintainers/greg.1.anderson)

---

Top Contributors

[![greg-1-anderson](https://avatars.githubusercontent.com/u/612191?v=4)](https://github.com/greg-1-anderson "greg-1-anderson (39 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/drush-example-drush-extension/health.svg)

```
[![Health](https://phpackages.com/badges/drush-example-drush-extension/health.svg)](https://phpackages.com/packages/drush-example-drush-extension)
```

###  Alternatives

[drush/drush

Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

2.4k57.4M683](/packages/drush-drush)[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[pantheon-systems/terminus

A command line interface for Pantheon

3391.5M13](/packages/pantheon-systems-terminus)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M18](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
