承接 piwi/composer-symlinker 相关项目开发

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

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

piwi/composer-symlinker

Composer 安装命令:

composer require piwi/composer-symlinker

包简介

A composer plugin to install packages as local symbolic links

README 文档

README

A Composer plugin to install packages as local symbolic links.

This plugin is a temporary implementation of using symbolic links to local packages as dependencies to allow a parallel work process. For a descriptive (and commented) problematic, see composer/composer#1299.

Usage

To use it, just add it as a dependency in your composer.json:

"piwi/composer-symlinker": "dev-master"

You must define concerned local paths or packages as extra config entries:

  • local-dirs: a list of local paths to scan while searching a local version of a package ; the final package path will be completed with vendor/package ;
  • local-packages: an array of vendor/package => local_path items ;
  • local-vendors: a list of vendors to restrict local scanning.
"extra": {
    "local-dirs": [
        "/my/absolute/local/path1",
        "/my/absolute/local/path2"
    ],
    "local-vendors": [
        "vendor1",
        "vendor2"
    ],
    "local-packages": {
        "vendor/package1": "/my/absolute/path/to/vendor/package1",
        "vendor/package2": "/my/absolute/path/to/vendor/package2"
    }
}

Windows users warning

The plugin uses the internal symlink() PHP function. See Windows restrictions on the manual.

Quick tutorial

Let's say we want to work on a project named MyProject base on three dependencies: MyPackage1 and MyPackage2 which are some of our packages, and a third-party ExternalPackage which is not. Let's say our localhost architecture is the following:

[DOCUMENT_ROOT]
|
|projects/
|-------- MyVendor/
|----------------- MyPackage1/      // this is a clone of MyVendor/MyPackage1
|
|MyPackage2/                        // this is a clone of MyVendor/MyPackage2
|
|MyProject/                         // this is the project we currently work on
                                    // which depends on other three packages

Note: MyVendor/MyPackage1 and MyVendor\MyPackage2 must exist in some composer repository already before they can be considered by composer to be installed or symlinked. Typically, packages will already be accessible via Packagist. But if they are local only (no already configured repository) then a local one will need to be added to your composer.json. It might look like this:

  "repositories": [
    {
      "type":"vcs",
      "url":"/path/to/DOCUMENT_ROOT/projects/MyVendor/MyPackage1"
    }
  ]

As we want to work on both MyProject and its dependencies MyPackageX, we would usually first install our dependencies with Composer (as hard copies), to let it create a valid autoload.php, then we would manually replace these hard copies by local symbolic links to our clones of MyPackage1 and MyPackage2 ...

Well, the plugin can do this for us, as long as we well-configure it and forces Composer to use it when installing our dependencies.

The common way to force Composer to use the plugin when installing a dependency should be to include it in its require statement. In our case, this is not relevant as we only want to use it to build our local environment (it must not be a requirement for other users). A good way to do so is to create a "development-only" composer's configuration file for our project to let us install local dependencies with the plugin in our environment but let final users have a "real-life" behavior (the default one).

Our "development-only" composer.json could be:

"require": {
    "piwi/composer-symlinker": "1.*"
},
"require-dev": {
    "MyVendor/MyPackage1": "dev-master",
    "MyVendor/MyPackage2": "dev-master",
    "OtherVendor/ExternalPackage": "dev-master"
},
"extra": {
    "local-dirs": "/path/to/DOCUMENT_ROOT/projects/",
    "local-packages": {
        "MyVendor/MyPackage2": "/path/to/DOCUMENT_ROOT/MyPackage2"
    }
}

This way, we may first run:

$ composer install --no-dev

to install the plugin, then:

$ composer update

will use it to install all packages.

Our final vendor directory should be something like:

[vendor]
|
|MyVendor/
|--------- MyPackage1   => /path/to/DOCUMENT_ROOT/projects/MyVendor/MyPackage1 (symlink)
|--------- MyPackage2   => /path/to/DOCUMENT_ROOT/MyPackage2 (symlink)
|
|OtherVendor/
|----------- ExternalPackage/ (hard copy)

and our autoloader will be still valid.

piwi/composer-symlinker 适用场景与选型建议

piwi/composer-symlinker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.15k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2015 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 18
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-03-15