定制 macfja/composer-phar-bin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

macfja/composer-phar-bin

Composer 安装命令:

composer require macfja/composer-phar-bin

包简介

Composer plugin to replace dev dependencies by Phar

README 文档

README

The plugin replace development dependencies by their Phar.

Why ?

I encounter several times a dependency lock on dev tool (code quality, documentation generation, etc.), and most of the time those tool have a Phar binary.

To manage those Phar, solution already exist, like Phive, but it's an another tool to install, another set of commands to run.

So, I create this Composer plugin to integrate Phive into Composer in the less visible way.

How it's works ?

When run composer install, composer update, or composer require, the plugin will check if any of your require-dev packages exist in the Phive repository. If found then Phive will link the Phar in your composer binaries so scripts will continue to work and the dependency will be ignore (so its sub-dependencies).

Installation

Simply run: composer require macfja/composer-phar-bin, and then a composer install.
Or globally: composer global require macfja/composer-phar-bin.

Any later composer install, composer update, or composer require will trigger the dependencies replacement.

How prevent a package to be replace ?

If for some reason need a package known by Phive to not be replace by its Phar, you can add in you (root) composer.json a list of package to don't replace.

In the extra section add composer-phar-bin object that contains an array named exclude of Composer packages.

Example

In the following example, phpunit/phpunit will be downloaded and managed by Composer, but phan/phan will be replace by its Phar.

{
    "name": "macfja/composer-phar-bin-test",
    "require-dev": {
        "macfja/composer-phar-bin": "^1.0.0",
        "phpunit/phpunit": "^9.1",
        "phan/phan": "^2.7"
    },
    "extra": {
        "composer-phar-bin": {
            "exclude": ["phpunit/phpunit"]
        }
    }
}

Limitation

The plugin only work after been installed. That seem obvious but there are cases which are tedious to understand because of this.

Dependencies conflicts on new a environment

Let's imagine that you use the plugin and you have virtually some conflict. Everything work fine, the plugin replace conflicting libraries with their Phar.

Someone want to install the project, but Composer complaint about some packages ("Your requirements could not be resolved to an installable set of packages.").

The reason is probably because you don't commit your composer.lock file, so Composer is trying to solve all dependencies, and as our plugin is not yet installed and loaded, it can't do its magic.

How to solve this ?

You have several solutions to solve this:

  • you can commit your composer.lock file
  • you can generate it gradually: remove all dev dependencies, then install your project (composer install), and now readd all you dev dependencies
  • you can install the plugin globally (so it will always be loaded)

Missing phars on fresh install

You download a project with a composer.lock, run composer install.

Everything seem ok, but when you first run a composer script, Composer complain about missing file.

The issue here is that the Composer read the composer.lock file, and so only install your dependencies, excluding the ones that are manage by our plugin. But as the plugin is not loaded (because not yet installed) it doesn't install phar.

How to solve this ?

You have two options:

  • simply rerun composer install
  • install the plugin globally (so it will always be loaded)

Contributing

You can contribute to the library. To do so, you have Github issues to:

  • ask your question
  • request any change (typo, bad code, etc.)
  • and much more...

You also have PR to:

  • suggest a correction
  • and much more...

Local installation

First clone the project (either this repository, or your fork), next run:

make install # Install project vendor
make all # Run QA tools + generate docs

Validate your code

When you done writing your code run the following command check if the quality meet defined rule and to format it:

make analyze # Run QA tools

License

The MIT License (MIT). Please see License File for more information.

macfja/composer-phar-bin 适用场景与选型建议

macfja/composer-phar-bin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 04 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「plugin」 「composer」 「phar」 「phive」 「phar-io」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 macfja/composer-phar-bin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 macfja/composer-phar-bin 我们能提供哪些服务?
定制开发 / 二次开发

基于 macfja/composer-phar-bin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-05