lapsrj/wp-dependencies-manager
Composer 安装命令:
composer require lapsrj/wp-dependencies-manager
包简介
Library that helps WordPress plugin dependency management.
README 文档
README
- Tags: plugin, dependency, install
- Requires at least: 5.1
- Requires PHP: 5.6
- License: MIT
A lightweight WordPress library for managing plugin dependencies. Declare required and recommended plugins via JSON, auto-install and activate them, and provide admins with a Dependencies page under the Plugins menu. Supports WordPress.org, GitHub, GitLab, Bitbucket, Gitea, direct URLs, and bundled ZIP files.
Based on WP Dependency Installer.
Description
You can use composer to install this package within your WordPress plugin / theme.
- Within your plugin or theme root folder, run the following command:
composer require lapsrj/wp-dependencies-manager
- Then create a
wp-dependencies.jsonfile:
[
{
"name": "Classic Editor",
"host": "wordpress",
"slug": "classic-editor/classic-editor.php",
"uri": "https://wordpress.org/plugins/classic-editor/",
"required": true
},
{
"name": "Query Monitor",
"host": "wordpress",
"slug": "query-monitor/query-monitor.php",
"uri": "https://wordpress.org/plugins/query-monitor/",
"optional": true
}
]
- Add the following lines to your plugin or theme's
functions.phpfile:
require_once __DIR__ . '/vendor/autoload.php'; add_action( 'after_setup_theme', static function() { WP_Dependencies_Manager::instance( __DIR__ )->run(); });
For plugins, use the plugins_loaded hook instead of after_setup_theme.
Bundled Plugins (Local ZIP)
You can bundle plugin ZIP files directly within your theme or plugin to distribute premium or private plugins. Place the ZIP file in a directory (e.g. bundled-plugins/) and reference it using "host": "local":
{
"name": "My Premium Plugin",
"host": "local",
"slug": "my-premium-plugin/my-premium-plugin.php",
"uri": "bundled-plugins/my-premium-plugin.zip",
"required": true
}
The uri is a relative path from your theme or plugin root to the ZIP file.
Using PHP instead of JSON
You can also register dependencies programmatically, which works the same way for bundled plugins:
require_once __DIR__ . '/vendor/autoload.php'; add_action( 'after_setup_theme', static function() { $manager = WP_Dependencies_Manager::instance( __DIR__ ); $manager->register( [ [ 'name' => 'My Premium Plugin', 'host' => 'local', 'slug' => 'my-premium-plugin/my-premium-plugin.php', 'uri' => 'bundled-plugins/my-premium-plugin.zip', 'required' => true, ], [ 'name' => 'Classic Editor', 'host' => 'wordpress', 'slug' => 'classic-editor/classic-editor.php', 'uri' => 'https://wordpress.org/plugins/classic-editor/', 'required' => true, ], ], __DIR__ ); $manager->run(); });
When using register() directly, pass the caller directory as the second argument so that local paths resolve correctly.
REST API
Declared dependencies can be listed, installed, and activated over the WordPress REST API. Unlike core's wp/v2/plugins endpoint (which only installs from WordPress.org by slug), these routes work for every source this library supports — GitHub, Bitbucket, GitLab, Gitea, direct URLs, and bundled local ZIPs. The routes are scoped to declared dependencies only, so this is not a general-purpose "install any plugin" endpoint.
Namespace: wp-dependencies-manager/v1
| Method | Route | Capability | Description |
|---|---|---|---|
GET |
/dependencies |
install_plugins |
List declared dependencies with installed / active / required status. |
POST |
/dependencies/install |
install_plugins + update_plugins |
Install the dependency (and activate it if it is required). |
POST |
/dependencies/activate |
activate_plugins |
Activate an already-installed dependency. |
Both POST routes take a slug parameter (the plugin file, e.g. classic-editor/classic-editor.php) in the request body.
Authenticate with an Application Password (WordPress 5.6+):
# List declared dependencies and their status curl https://example.com/wp-json/wp-dependencies-manager/v1/dependencies \ --user "admin:xxxx xxxx xxxx xxxx xxxx xxxx" # Install a dependency curl -X POST https://example.com/wp-json/wp-dependencies-manager/v1/dependencies/install \ --user "admin:xxxx xxxx xxxx xxxx xxxx xxxx" \ -d "slug=classic-editor/classic-editor.php" # Activate a dependency curl -X POST https://example.com/wp-json/wp-dependencies-manager/v1/dependencies/activate \ --user "admin:xxxx xxxx xxxx xxxx xxxx xxxx" \ -d "slug=classic-editor/classic-editor.php"
The routes are registered only when at least one dependency is declared (they hook into rest_api_init from load_hooks()).
Contributors
- Leandro
- Andy Fragen (original author)
- Matt Gibbs (original author)
- Raruto (original author)
lapsrj/wp-dependencies-manager 适用场景与选型建议
lapsrj/wp-dependencies-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 105 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lapsrj/wp-dependencies-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lapsrj/wp-dependencies-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 105
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-23