承接 milpa/plugin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

milpa/plugin

Composer 安装命令:

composer require milpa/plugin

包简介

GitHub-native plugin distribution for the Milpa PHP framework: source parsing, semver-constrained release resolution, zipball download, milpa.json manifest reading/validation, dependency resolution, milpa.lock management, and contract-based load ordering.

README 文档

README

Milpa

Milpa Plugin

GitHub-native plugin distribution for the Milpa PHP framework — semver-aware version resolution, manifest validation, dependency ordering, and a lock file, with no registry server required.

CI Packagist PHP License Docs

milpa/plugin is the distinct-value core behind a Milpa host's plugin require owner/repo command: resolve a semver constraint against GitHub releases/tags, download and extract the matching zipball, read and validate the plugin's milpa.json manifest, resolve its plugin + Composer dependencies, order every installed plugin by the contracts it provides/requires, and record the result in a milpa.lock file. No registry server, no Packagist-style index — GitHub itself is the source of truth.

Install

composer require milpa/plugin

Quick example

use Milpa\Plugin\ContractResolver;
use Milpa\Plugin\DependencyResolver;
use Milpa\Plugin\GitHubDownloader;
use Milpa\Plugin\LockFileManager;
use Milpa\Plugin\PluginManifest;

// 1. Parse a GitHub source string into owner/repo/constraint.
$downloader = new GitHubDownloader();
$downloader->parseSource('acme/mail-plugin:^2.0');
// -> ['owner' => 'acme', 'repo' => 'mail-plugin', 'constraint' => '^2.0']

// 2. Read + validate a milpa.json manifest (fromArray() mirrors fromPath()).
$manifest = PluginManifest::fromArray([
    'name' => 'acme/mail-plugin',
    'version' => '2.1.0',
    'entrypoint' => 'MailPlugin.php',
    'namespace' => 'Acme\\MailPlugin',
    'contracts' => ['requires' => ['database']],
]);
$manifest->validate(); // throws InvalidArgumentException on a malformed manifest

// 3. Order plugins by their declared contracts (Kahn's algorithm; throws on cycles).
$resolver = new ContractResolver();
$loadOrder = $resolver->getLoadOrder([
    ['name' => 'DatabasePlugin', 'class' => 'Acme\\DatabasePlugin', 'provides' => ['database']],
    ['name' => 'acme/mail-plugin', 'class' => 'Acme\\MailPlugin', 'requires' => ['database']],
]);
// -> load order: DatabasePlugin, acme/mail-plugin (providers before consumers)

// 4. Resolve dependencies before installing (plugin deps, contracts, composer.lock).
$deps = new DependencyResolver(getcwd());
$resolution = $deps->resolve($manifest, [
    ['name' => 'DatabasePlugin', 'provides' => ['database']],
]);
// -> $resolution->resolvable === true, $resolution->conflicts === []

// 5. Record installed state in milpa.lock.
$lock = new LockFileManager(getcwd());
$lock->generate([
    ['name' => 'acme/mail-plugin', 'version' => '2.1.0', 'source' => 'github:acme/mail-plugin'],
]);
$lock->verify(); // true — the SHA-256 content hash matches

What lives where

Class Responsibility
GitHubDownloader Parses owner/repo[:constraint] / full GitHub URLs, lists releases/tags via the GitHub REST API, resolves the best version for a constraint, and downloads + extracts the matching zipball. Reads GITHUB_TOKEN for private repos or higher rate limits.
PluginManifest Reads and validates a milpa.json manifest (fromPath() / fromArray()), exposes typed accessors (getProvides(), getRequires(), getSuggests(), typed CapabilityProvision/CapabilityRequirement/CapabilitySuggestion records, Composer/plugin dependencies, PHP version constraint, env vars), and can generate a manifest skeleton from #[PluginMetadata] attributes.
ContractResolver Validates that every plugin's requires is satisfied by some other plugin's provides (fail-fast, throws RuntimeException; suggests only logs), and topologically sorts plugins into a load order where providers come before consumers.
DependencyResolver Resolves a plugin's contract requirements, plugin-to-plugin dependencies (with version constraint checks), and Composer dependencies (read from composer.lock) into a single Milpa\DTO\DependencyResolutionresolvable, conflicts, missingPlugins, composerPackages, satisfiedContracts.
LockFileManager Generates, reads, and verifies milpa.lock — installed plugin names, versions, sources, install timestamps, and a SHA-256 content hash for integrity checks.

Requirements

Documentation

Full API reference: getmilpa.github.io/plugin — generated straight from the source DocBlocks and dressed with the Milpa design system.

Contributing

Contributions are welcome — see CONTRIBUTING.md. Please report security issues via SECURITY.md, and note that this project follows a Code of Conduct.

License

Apache-2.0 © TeamX Agency.

Milpa is designed, built, and maintained by TeamX Agency.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固