steady-ua/unicorn
Composer 安装命令:
composer require steady-ua/unicorn
包简介
Composer monorepo plugin
README 文档
README
The composer plugin organizes a mono-repository of php packages.
Ensures the consistency of all dependencies on the same package version.
Adds tools for working with shared dependencies.
Concept
For example, we have two projects:
- the
webproject serves http requests - the
workerproject for background processes
Both projects use common packages placed in the packages directory
apps/
web/
index.php
composer.json
worker/
console.php
composer.json
packages/
foo/
composer.json
bar/
composer.json
composer.json # monorepo definition root config
Raw composer - provides the ability to include local packages by specifying your own path repository.
But there are a number of limitations, such as:
- in each
composer.jsonfile you must describe all local repositories. - each package has its own local file, and it is possible that packages of different versions are used.
- difficult to analyze package usage.
- difficult to update dependencies used in different packages.
The steady-ua/unicorn plugin removes these restrictions and provides tools for analyzing and updating dependencies.
Why Unicorn instead of other Monorepo tools?
Unlike tools that merge all composer.json files into a single root file, unicorn works as a native Composer v2 plugin.
- Native Dependency Resolution: All monorepo packages are registered in a local Composer registry. This delegates validation entirely to Composer's native SAT solver. To add a dependency, simply navigate to the needed package and run
composer require my/foo. Composer will naturally prevent version conflicts (e.g., trying to install different versions of a third-party library across the monorepo) and will automatically detect and prevent circular dependencies during installation. - Semantic Versioning at the Core: The entire architecture revolves around semantic versioning. Each package must define its version in
composer.json(e.g.,"version": "1.0.0"). To simplify workflows, theuni:versioncommand automates version bumping, updates the constraints in any dependent local packages, and runs configured tests or scripts. For external dependencies, theuni:updatecommand simplifies third-party package migration by synchronizing updates and running tests across all dependent local packages. - Dependency Analysis & Visualization: Includes built-in commands like
uni:whyanduni:why-notto trace dependency paths across the monorepo, as well as an interactive browser-based dependency graph visualization using theuni:servercommand. - Isolated Contexts: For development, a shared
vendorfolder is created at the project root. However, packages remain self-sufficient. Each package retains its owncomposer.jsonand gets its own localvendordirectory where only its explicitly required dependencies are installed via symlinks. This prevents accidental reliance on undeclared packages and allows you to run dependency analysis tools accurately at the individual package level. - Smart CI capabilities: Commands like
uni:runallow you to execute scripts (e.g., tests or linters) recursively up the dependency tree, ensuring that changes in a base package don't break downstream dependents without having to run tests for the entire monorepo. - Distribution and Release: Solves common monorepo deployment issues.
Theuni:buildcommand extracts an independent, ready-to-run application with only its strictly required dependencies, making it perfect for Docker builds or direct deployment without dragging the entire monorepo along.
Additionally, theuni:splitcommand automates the publishing of local packages to separate, read-only repositories. This allows external projects outside the monorepo to easily require your shared packages via standard Composer installations.
Documentation
For a detailed guide on how to work with Unicorn, check out the docs/ directory:
steady-ua/unicorn 适用场景与选型建议
steady-ua/unicorn 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 steady-ua/unicorn 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 steady-ua/unicorn 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-04-29