This composer plugin is a temporary implementation of using symbolic links to local packages as dependencies to allow a parallel work process

Overview

Composer symlinker

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 https://github.com/composer/composer/issues/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.

You might also like...
Ied plugin composer - Inspired Plugin Composer: Create, publish and edit plugins from within Textpattern CMS.

ied_plugin_composer Create, publish and edit plugins from within Textpattern CMS. Creates a new page under the Extensions tab where you can edit and e

PHP Parallel Lint - This tool check syntax of PHP files faster than serial check with fancier output
PHP Parallel Lint - This tool check syntax of PHP files faster than serial check with fancier output

PHP Parallel Lint This application checks syntax of PHP files in parallel. It can output in plain text, colored text, json and checksyntax formats. Ad

A PHP Library To Make Your Work Work Easier/Faster

This Is A Php Library To Make Your Work Easier/Faster,

Applies a patch from a local or remote file to any package that is part of a given composer project.

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level in package config or separate JSON file. Declaration-free mode (using embedded info within patch files) is available as well.

Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion.
Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion.

Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion. HTTP API, HTTPs support, webhook handler, scheduled builds, Slack and HipChat integration.

Private Composer registry for private PHP packages on AWS Serverless
Private Composer registry for private PHP packages on AWS Serverless

Tug Tug is a Composer private registry for private PHP packages installable with Composer (1 and 2). The main idea of this project is to have an inter

A workbench for developing Composer packages.

studio Installation Usage Workflow Command Reference License Contributing For enterprise Develop your Composer libraries with style. This package make

Installed composer packages info

PackageInfo This package was highly inspired from ocramius/package-versions I needed some methods to read data from the composer.lock file fast...this

Composer addon to efficiently get installed packages' version numbers

Package Versions composer/package-versions-deprecated is a fully-compatible fork of ocramius/package-versions which provides compatibility with Compos

Comments
  • "Not Working"

    I hate when people just say its "not working" but I don't have enough experience with composer plugins to be able to be of specific help.

    I've set breakpoints on all the public methods inside LocalInstaller and outside of construction, the class is never consulted. I've added the following to my composer.json's extra section:

        "local-dirs": "/Users/ralphschindler/Projects/distillphp",
        "local-packages": {
          "distill/mapper": "/Users/ralphschindler/Projects/distillphp/distill-mapper"
        }
    

    I can see the constructor is working, and the state of the object seems correct at the end of construction: But then LocalInstaller is never asked to install/symlink anything.

    ~~Does the target package have to exist in a repository first? Like inside packagist or a local repository?~~

    Update: Yes, a local repository is required if it is not already in another repository. Also, I'll turn this into a PR for an update to the README, and another issue I found.

    opened by ralphschindler 2
Owner
Pierre Cassat
I am a web lead-developer and DevOps under open source environment
Pierre Cassat
Opinionated version of Wikimedia composer-merge-plugin to work in pair with Bamarni composer-bin-plugin.

Composer Inheritance Plugin Opinionated version of Wikimedia composer-merge-plugin to work in pair with bamarni/composer-bin-plugin. Usage If you are

Théo FIDRY 25 Dec 2, 2022
Allow composer packages to define compilation steps

Composer Compile Plugin The "Compile" plugin enables developers of PHP libraries to define free-form "compilation" tasks, such as: Converting SCSS to

CiviCRM 11 Aug 3, 2022
Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins.

Imposter Plugin Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins. Built with ♥ by Typ

Typist Tech 127 Dec 17, 2022
Composer Repository Manager for selling Magento 2 extension and offering composer installation for ordered packages.

Magento 2 Composer Repository Credits We got inspired by https://github.com/Genmato. Composer Repository for Magento 2 This extension works as a Magen

EAdesign 18 Dec 16, 2021
Plugin for composer to apply patches onto dependencies.

composer-patches-plugin This plugin allows you to provide patches for any package from any package. If you don't want a patch package outside the root

Netresearch 75 Aug 7, 2022
Composer bin plugin — Isolate your bin dependencies

Composer bin plugin — Isolate your bin dependencies Table of Contents Why? How does this plugin work? Installation Usage Example The all bin namespace

Bilal Amarni 394 Jan 7, 2023
Windowy is a transaction-focused temporary inventory generator made for PocketMine-MP

About Windowy is a transaction-focused temporary inventory generator made for PocketMine-MP. How to use Windowy comes with 3 registered inventories us

DayKoala ʕ•ᴥ•ʔ 19 Aug 12, 2022
yform 4 usability addon (temporary until yform gets its own)

massif_usability Package für REDAXO CMS >= 5.10.0 temporäres Ersatz-Plugin für yform_usability für yform >=4 – bietet ähnliche Funktionalität wie yfor

Yves Torres 6 Mar 4, 2022
This composer plugin allows you to share your selected packages between your projects by creating symlinks

Composer - Shared Package Plugin This composer plugin allows you to share your selected packages between your projects by creating symlinks. All share

L'Etudiant 169 Sep 20, 2022