and/isolate-composer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

and/isolate-composer

Composer 安装命令:

composer require and/isolate-composer

包简介

Isolates composer dependencies by prefixing namespace for all vendor code within a project

README 文档

README

What this plugin does

This plugin prefixes all vendor namespaces with a chosen value. This includes all declared namespaces, use statements, fully qualified references, and most string values that reference the namespace.

All vendor code and composer autoload mappings are updated to reference the prefixed namespace.

What this plugin does not do

It will not touch any code in your project. It only affects code in the vendor directory, and it only affects code referencing the affected namespaces. You must update all references in your code yourself if you apply this to an existing project.

Why would I want to use this?

This plugin allows you to run two projects that utilize composer dependencies in the same runtime, without worrying about conflicting dependencies. The most common example is in a WordPress environment, where all plugins execute in the same runtime, and may rely on the same composer dependencies. Each project utilizing the plugin can't conflict with any other project unless the vendor code is not namespaced (in which case there aren't many options...).

Usage

Using the plugin is straightforward. Install the plugin by requiring it in your project: composer require and/isolate-composer.

Configure the plugin by adding the following to your composer.json:

"config" : {
    "isolate": {
      "prefix": "Your\\Prefix\\Here\\",
      "blacklist": [],
      "autorun": false,
      "require-dev": false,
      "replacements" : {}
    }
}

The only required value is the prefix.

After you have configured the plugin, run the isolation:

composer isolate
composer dump

Your vendor code is now prefixed!

Be sure to dump after you isolate, or your autoload mappings will be incorrect!

Configuration

prefix

This is the value that will be prepended to all vendor namespaces. It should be a valid namespace, and should be unique to your project. I recommend you don't use your main project namespace, or at least add \\Vendor to the end.

blacklist

This is a list of packages you don't want to prefix. Matching packages will not be scanned for namespaces, but will still have code rewritten if it contains namespaces from other non-blacklisted packages.

autorun

Setting this value to true automatically runs the isolation process before every dump.

require-dev

By default, only require packages are scanned for namespaces, and require-dev packages are ignored (as above, they will still have code rewritten if they contain namespaces from other packages).

Setting this value to true includes the require-dev packages in the scan, and any found namespaces will be prefixed.

replacements

This is a place for manually fixing things in the vendor code that either were not detected and replaced, or replaced when they should not have been.

After each file has been parsed and rewritten, if there is an entry in the replacements list, it will do a string replace on the file.

String replacements should be idempotent, or things will break on multiple executions.

The syntax is:

"replacements" : {
    "path/relative/to/vendor/root/file.php" : {
        "search" : "replace",
        "search" : "replace",
    },
    "path/relative/to/vendor/root/file.php" : {
            "search" : "replace",
            "search" : "replace",
        }
}

and/isolate-composer 适用场景与选型建议

and/isolate-composer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.73k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2018 年 06 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-07