freezysko / composer-wp-plugin-activator
Auto-activate Composer-installed WordPress plugins via post-install/post-update hooks. Zero-config; works with Bedrock, WP Packages, WPackagist.
Package info
github.com/freezysko/composer-wp-plugin-activator
Type:composer-plugin
pkg:composer/freezysko/composer-wp-plugin-activator
Requires
- php: ^8.1
- composer-plugin-api: ^2.2
Requires (Dev)
- composer/composer: ^2.0
- friendsofphp/php-cs-fixer: ^3.0
- icanhazstring/composer-unused: ^0.8
- maglnet/composer-require-checker: ^4.0
- phpmd/phpmd: ^2.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^10.1
- roave/security-advisories: dev-latest
- tomasvotruba/cognitive-complexity: ^1.0
- dev-main
- v1.0.0-beta.1
- dev-docs/E-4-readme-polish
- dev-docs/E-3-examples
- dev-docs/E-2-contributing
- dev-docs/E-1-community-files
- dev-ci/B-4-coverage-mutation-workflows
- dev-test/B-3-mutation-gap
- dev-chore/B-1-tooling-setup
- dev-fix/A-followup-composer-unused-wrap
- dev-ci/A-6-quality-workflow
- dev-chore/A-5-composer-scripts
- dev-chore/A-4-composer-audits
- dev-feat/A-3-phpmd-cyclomatic
- dev-feat/A-2-phpstan-extensions
- dev-chore/A-1-php-cs-fixer-setup
- dev-docs/C-9-security-md-final
- dev-fix/C-8-audit-findings
- dev-fix/C-6-config-validation-hardening
- dev-chore/C-5-sha-pin-third-party-actions
- dev-docs/C-7-readme-known-limitations
- dev-fix/C-2-semgrep-config
- dev-ci/C-2-semgrep
- dev-docs/C-1-threat-model
- dev-ci/C-4-composer-audit-cron
- dev-chore/C-3-roave-security-advisories
- dev-chore/D-11-branch-protection
- dev-docs/D-10-agents-subagent-protocol
- dev-docs/D-9-readme-badges
- dev-docs/D-8-security-stub
- dev-fix/D-3-commitlint-body-length
This package is auto-updated.
Last update: 2026-05-20 22:08:41 UTC
README
A Composer plugin that auto-activates Composer-installed WordPress plugins via
WP-CLI on composer install / composer update — no scripts wiring, no
per-request overhead, no MU-plugin tricks.
Quick start
Require the package:
composer require freezysko/composer-wp-plugin-activator
Then allow the plugin to run. Composer 2.2+ blocks plugin code unless it is explicitly allowed — without this entry the package installs but does nothing:
{
"config": {
"allow-plugins": {
"freezysko/composer-wp-plugin-activator": true
}
}
}
That's it. The next composer install / composer update will activate your
plugins via WP-CLI. The package self-registers — no scripts wiring needed.
For ready-to-copy composer.json setups see
examples/: Bedrock,
vanilla WordPress, and
custom activation order.
Requirements
- PHP 8.1+
- Composer 2.x
- WP-CLI available on the machine running Composer
Configuration
All keys are optional. Add an extra.composer-wp-plugin-activator section to
your composer.json:
{
"extra": {
"composer-wp-plugin-activator": {
"wp-cli": "wp",
"wp-path": null,
"plugins": "composer",
"priority": [],
"skip-when-wp-not-installed": true,
"verbose": false,
"fail-on-error": false,
"allow-root": "auto"
}
}
}
| Key | Type | Default | Description |
|---|---|---|---|
wp-cli |
string | "wp" |
Path to the WP-CLI binary. |
wp-path |
string | null | null |
Value for WP-CLI's --path=. null lets WP-CLI auto-detect via wp-cli.yml. |
plugins |
string | array | "composer" |
"composer", "all", or an explicit ordered list of slugs. See below. |
priority |
array | [] |
Slugs to activate before the main plugins pass (foundational plugins like WooCommerce). See "Plugin activation order". |
skip-when-wp-not-installed |
bool | true |
If wp core is-installed is false, exit cleanly. Recommended for fresh installs. |
verbose |
bool | false |
Stream full WP-CLI output even on success. |
fail-on-error |
bool | false |
If true, a WP-CLI failure aborts Composer with a non-zero exit code. |
allow-root |
bool | string | "auto" |
--allow-root handling. "auto" adds it when running as root; true/false force it on/off. |
plugins modes
"composer"(default) — activates only plugins installed by Composer (packages of typewordpress-plugin). Slugs are derived from each package's install directory. Safe and package-scoped: it does not touch manually-dropped or third-party plugins."all"— runswp plugin activate --all, activating every plugin in the plugins directory, Composer-managed or not. Opt-in; remember that activation can run migrations, schedule cron, or call external services.- array — explicit, ordered list, e.g.
["woocommerce", "polylang"]. Activated in order, so foundation plugins can precede dependents. Invalid entries (leading-, whitespace, disallowed characters) are skipped with a warning. Entries containing/(e.g.wpackagist-plugin/woocommerce) are treated as Composer package names and normalized to the part after the last/— write the WP slug directly to avoid the warning.
Invalid plugins values fail closed. A typo such as "plugins": "everthing"
is treated as "activate nothing" with a warning, preventing an unintentional
wp plugin activate --all from a configuration mistake.
Plugin activation order
WordPress 6.5+ supports Requires Plugins: headers and WP-CLI enforces them,
but it activates plugins alphabetically — so a dependent plugin can fail on
its first pass when its dependency hasn't run yet. The package handles this in
two layers:
prioritylist (recommended for known blockers). Slugs listed inpriorityare activated first, in order, before the mainpluginspass — use it for foundational plugins like WooCommerce that many others extend. Seeexamples/custom-priority.md. Invalid or Composer-style (/-containing) entries are normalized or skipped with a warning.- Bounded retry loop (safety net). After the main pass, any pass that activates at least one plugin triggers another, up to five total passes. A pass that activates nothing new stops the loop — remaining failures are real (missing plugin, real error).
priority is ignored when plugins is an explicit array, since the array
already controls order; a warning is emitted so operators notice. A
priority-pass failure does not stop the main pass, but it is surfaced as an
error and preserved in the exit code, so fail-on-error: true still aborts
Composer when a priority slug fails.
Bedrock integration
Works zero-config in Bedrock projects — WP-CLI
auto-detects the WordPress path, so wp-path can stay null. See
examples/bedrock.md.
Limitations
- Multisite — network activation is out of scope for v1; plugins are activated site-locally only.
- No plugin installation — this package only activates. Installing
plugins is Composer's job (via
composer/installers+ wpackagist). - No auto-deactivation — removing a plugin from
composer.jsonremoves it from disk; WordPress handles activation-state cleanup on the next request. - No dependency-header parsing — the package re-runs activation until
WordPress's own
Requires Plugins:checks pass (capped at 5 passes); it does not parse headers or use Composer's dependency graph itself. - English-locale summary — the "already active" vs "activated N" summary is parsed from English WP-CLI output. Under a non-English locale the summary may be less precise; activation itself is unaffected.
The full list of in-scope and out-of-scope attack classes for v1.0.x is in
.github/SECURITY-THREAT-MODEL.md. To
report a vulnerability see SECURITY.md.
Troubleshooting
wp-cli not foundwarning, activation skipped — the WP-CLI binary check (wp --version) failed. Setwp-clito the binary's full path (e.g./usr/local/bin/wp) ifwpis not on thePATHof the process running Composer.WordPress not installed yetinfo line, activation skipped —wp core is-installedreturned false. This is expected on a fresh build beforewp core installhas run or before the database is provisioned. It is controlled byskip-when-wp-not-installed(defaulttrue); set it tofalseto treat this as an error instead.wp-cli reported an error, a plugin failed to activate — setverbosetotrueto stream the full WP-CLI output and see the underlying failure (e.g. a genuinely missingRequires Plugins:dependency). By default the failure is reported but Composer still succeeds; setfail-on-errortotrueto make a WP-CLI failure abort Composer with a non-zero exit code.
Contributing
Contributions are welcome. See CONTRIBUTING.md for
development setup, local checks, the contribution workflow, and an architecture
overview. By participating you agree to the
Code of Conduct.
License
MIT — see LICENSE.