PHPackages                             jparkinson1991/composer-linker-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jparkinson1991/composer-linker-plugin

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

jparkinson1991/composer-linker-plugin
=====================================

Enables linking/copying of package files to custom directories

3.1.3(3y ago)135[1 PRs](https://github.com/JParkinson1991/composer-linker-plugin/pulls)GPL-3.0-or-laterPHPPHP ^7.3 || ^8.0

Since Jan 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/JParkinson1991/composer-linker-plugin)[ Packagist](https://packagist.org/packages/jparkinson1991/composer-linker-plugin)[ RSS](/packages/jparkinson1991-composer-linker-plugin/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (13)Versions (21)Used By (0)

Composer Linker Plugin
======================

[](#composer-linker-plugin)

[![Packagist Version](https://camo.githubusercontent.com/73165d0e91b7442f026d36211320ee16c90e060dcdaaa9983767fe369c807c1b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a7061726b696e736f6e313939312f636f6d706f7365722d6c696e6b65722d706c7567696e3f6c6162656c3d76657273696f6e)](https://camo.githubusercontent.com/73165d0e91b7442f026d36211320ee16c90e060dcdaaa9983767fe369c807c1b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a7061726b696e736f6e313939312f636f6d706f7365722d6c696e6b65722d706c7567696e3f6c6162656c3d76657273696f6e) [![Packagist PHP Version Support](https://camo.githubusercontent.com/6f64201ab6292afbb28627d752bfdc1ebc5b93fef89f044eebb23889cdf6166a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a7061726b696e736f6e313939312f636f6d706f7365722d6c696e6b65722d706c7567696e)](https://camo.githubusercontent.com/6f64201ab6292afbb28627d752bfdc1ebc5b93fef89f044eebb23889cdf6166a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a7061726b696e736f6e313939312f636f6d706f7365722d6c696e6b65722d706c7567696e) [![Build & Test](https://github.com/JParkinson1991/composer-linker-plugin/actions/workflows/test.yml/badge.svg)](https://github.com/JParkinson1991/composer-linker-plugin/actions/workflows/test.yml) [![Coverage Status](https://camo.githubusercontent.com/bb23dc2bc3c3c4859e939209d35a15db664aeecc6040ac3033f9881b1377569d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4a5061726b696e736f6e313939312f636f6d706f7365722d6c696e6b65722d706c7567696e2f62616467652e737667)](https://coveralls.io/github/JParkinson1991/composer-linker-plugin) [![Packagist License](https://camo.githubusercontent.com/f1ab79b3bedd7902948f25077d1b22e09f23a1f989c880571c88b080c8c84a6c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a7061726b696e736f6e313939312f636f6d706f7365722d6c696e6b65722d706c7567696e)](https://camo.githubusercontent.com/f1ab79b3bedd7902948f25077d1b22e09f23a1f989c880571c88b080c8c84a6c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a7061726b696e736f6e313939312f636f6d706f7365722d6c696e6b65722d706c7567696e)

This plugin enables the movement of package files outside of the standard composer vendor directory via symlink or copying.

This plugin enables the following:

- Linking of entire package directory to a custom installation folder
- Linking of specific files from within a package to a custom install folder
    - Linked files can be renamed as required

Packages (or their specific files) will be linked as per configuration when it is either installed or updated and unlinked when uninstalled.

Any linked package will still exist within the composer vendor directory as well as any configured custom installation path.

Getting Started
---------------

[](#getting-started)

### Requirements

[](#requirements)

- A composer based PHP project.
- Composer `^2`
- PHP `^7.3 || ^8.0`

#### Composer 2.3.0 deprecations

[](#composer-230-deprecations)

This plugin knowingly consumes deprecated functionality within composer core to ensure its compatibility with all current versions of composer 2.x. Update to the latest version of composer to ensure that when this deprecated code is removed from the plugin your installation will not be effected.

### Installing

[](#installing)

```
$ composer require jparkinson1991/composer-linker-plugin

```

Usage
-----

[](#usage)

### Usage as a Plugin

[](#usage-as-a-plugin)

This plugin will invoke automatically after a package is *installed*, *updated* or *uninstalled*. To have that package handled by this plugin simply provide [configuration](#configuration) for it. Packages will be `linked` as per configuration on *install* and *update*. Packages will be `unlinked` as per configuration on *uninstall*.

All defined [configuration](#configuration) will be processed when this plugin is *installed* and *uninstalled*. On *install* all configuration will be `linked`. On *uninstall* all configuration will be `unlinked`.

### Usage via Commands

[](#usage-via-commands)

Commands can be used manually trigger a `link`/`unlink`. Commands will only be able to process that which exists in [configuration](#configuration).

#### Link Command

[](#link-command)

Link all packages as defined in configuration.

```
$ composer composer-linker-plugin:link
$ composer clp-link

```

Link a single package from configuration. *Package must be installed and configuration must exist for it.*

```
$ composer composer-linker-plugin:link package/name
$ composer clp-link package/name

```

Link a multiple packages from configuration. *Packages must be installed and configuration must exist for them.*

```
$ composer composer-linker-plugin:link package/name second/package third/package ...
$ composer clp-link package/name second/package third/package ...

```

#### Unlink Command

[](#unlink-command)

Unlink all packages as defined in configuration.

```
$ composer composer-linker-plugin:unlink
$ composer clp-unlink

```

Unlink a single package from configuration. *Package must be installed and configuration must exist for it.*

```
$ composer composer-linker-plugin:unlink package/name
$ composer clp-unlink package/name

```

Unlink a multiple packages from configuration. *Packages must be installed and configuration must exist for them.*

```
$ composer composer-linker-plugin:unlink package/name second/package third/package ...
$ composer clp-unlink package/name second/package third/package ...

```

Configuration
-------------

[](#configuration)

All plugin configuration exists within the `extra` section of the project's `composer.json` file under the `linker-plugin` key.

- [Simple Links](#simple-links)
- [Complex Links](#complex-links)
    - [Defining file mappings](#defining-file-mappings)
        - [Defining file mappings as an array](#defining-file-mappings-as-an-array)
        - [Defining file mappings as an object](#defining-file-mappings-as-an-object)
    - [Defining link level options](#defining-link-level-options)
- [Options](#options)
    - [Copying files](#copying-files)
    - [Deleting orphan directories](#deleting-orphan-directories)
    - [Default Implied Options](#default-implied-options)

### Simple Links

[](#simple-links)

In it's simplest form, this plugin can link a package directory to a given installation path.

```
{
    "extra": {
        "linker-plugin": {
            "links": {
                "vendor/package": "custom/install/dir"
            }
        }
    }
}

```

*Relative custom installation directories will be resolved from the project root. I.e. The directory containing the composer.json file. Absolute paths will be treat as is.*

### Complex Links

[](#complex-links)

For more granular control of links, complex link objects can be defined using an object with the structure below.

```
{
    "extra": {
        "linker-plugin": {
            "links": {
                "vendor/package": {
                    "dir": "custom/install/dir",
                    "files": ...,
                    "options": ...
                }
            }
        }
    }
}

```

When defining complex link objects the `dir` element is required. Both the `files` and `options` elements are optional. Empty `files` or `options` objects will be treat as an error. Do not include them if they are not needed.

#### Defining file mappings

[](#defining-file-mappings)

A selection of files from within the package directory can be handpicked to be linked only. If the `files` element of a complex link exists, **only those files will be linked**.

When definining file mappings:

- `Source files` are always treat as relative to the package's install directory.
- `File destinations`
    - If *relative*, are resolved from the link's custom installation directory.
    - If *absolute*, are treat as is.

**Important:** The same source file may be mapped to multiple destinations however each destination must be unique within the link definition.

File mappings can be defined as both objects and arrays.

##### Defining file mappings as an array

[](#defining-file-mappings-as-an-array)

```
{
    "extra": {
        "linker-plugin": {
            "links": {
                "vendor/package": {
                    "dir": "custom/install/dir",
                    "files": [
                        "PackageFile1.php",
                        {
                            "PackageFile2.php": "includes/PackageFile2.php",
                            "PackageFile3.php": {
                                "PackageFile3-Dest1.php",
                                "PackageFile3-Dest2.php"
                            }
                        }
                    ]
                }
            }
        }
    }
}

```

When using an array to define file mappings:

- *Flat strings* (`PackageFile1.php`)
    - Will be treat as having the source and destination
- *Key Value pairs* (`PackageFile2.php`)
    - Key will be treat as the source file
    - Value will be treat as the destination
- *Key to Multi Value objects* (`PackageFile3.php`)
    - Key will be treat as the source file
    - Each value of the object will be treat as a separate destination for that source file.

##### Defining file mappings as an object

[](#defining-file-mappings-as-an-object)

```
{
    "extra": {
        "linker-plugin": {
            "links": {
                "vendor/package": {
                    "dir": "custom/install/dir",
                    "files": {
                        "PackageFile1.php": "includes/PackageFile1.php",
                        "PackageFile2.php": {
                            "PackageFile2-Dest1.php",
                            "PackageFile2-Dest2.php"
                        }
                    }
                }
            }
        }
    }
}

```

When defining file mappings as an object, all mappings **must** define a `source file`.

- *Key Value pairs* (`PackageFile1.php`)
    - Key will be treat as the source file
    - Value will be treat as the destination
- *Key to Multi Value objects* (`PackageFile2.php`)
    - Key will be treat as the source file
    - Each value of the object will be treat as a separate destination for the source file.

#### Defining link level options

[](#defining-link-level-options)

To define link level options, include the `options` object within a complex link configuration.

```
{
    "extra": {
        "linker-plugin": {
            "links": {
                "vendor/package": {
                    "dir": "custom/install/dir",
                    "options": {}
                }
            }
        }
    }
}

```

Any of the [plugin options](#options) can be placed within a complex link configuration's `options` object.

Link level options will override any global options set for the plugin.

### Options

[](#options)

Plugin level options can be defined in the `options` object.

The `options` object is optional and if not included the [default implied options](#default-implied-options) will be used.

```
{
    "extra": {
        "linker-plugin": {
            "links": {},
            "options": {}
        }
    }
}

```

Any defined plugin option will be applied to all link configurations unless [overridden](#defining-link-level-options).

#### Copying files

[](#copying-files)

To enable the copying of files when linking, define the `copy` option with a `boolean` value.

```
{
    "extra": {
        "linker-plugin": {
            "links": {},
            "options": {
                "copy": true
            }
        }
    }
}

```

#### Deleting orphan directories

[](#deleting-orphan-directories)

If linking package's or their files to nested directories within a project, it may be useful to have the plugin delete the orphan directories of the link when it's associated package is uninstalled.

Directories are only treat as orphans if they are empty.

Orphan directories **will not** be cleaned outside of the composer project's root directory.

As an example

- Project root: `/var/www/composer-project`
- Linked directory: `/var/www/composer-project/nested/link/directory`
- Orphan directories after uninstall
    - `/var/www/composer-project/nested/link`
    - `/var/www/composer-project/nested`

To enable deletion of a link configurations's orphan directories after it's associated package is uninstalled, define the `delete-orphans` option with a `boolean` value.

```
{
    "extra": {
        "linker-plugin": {
            "links": {},
            "options": {
                "delete-orphans": true
            }
        }
    }
}

```

#### Default Implied Options

[](#default-implied-options)

The default implied options are as follows

```
{
    "extra": {
        "linker-plugin": {
            "links": {},
            "options": {
                "copy": false
                "delete-orphans": false
            }
        }
    }
}

```

Versioning
----------

[](#versioning)

[SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/JParkinson1991/composer-linker-plugin/tags).

License
-------

[](#license)

This project is licensed under the *GNU GPLv3 License* - see the [LICENSE](LICENSE) file for details

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 98.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~52 days

Recently: every ~14 days

Total

18

Last Release

1419d ago

Major Versions

1.3.0 → 2.0.02020-05-22

2.4.0 → 3.0.02022-04-29

PHP version history (2 changes)1.0.0PHP ^7.3

3.0.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9a012826a28e80946416d3d0ceaa67184f75f3be92703970b473bdcf429fe583?d=identicon)[JParkinson1991](/maintainers/JParkinson1991)

---

Top Contributors

[![JParkinson1991](https://avatars.githubusercontent.com/u/6921398?v=4)](https://github.com/JParkinson1991 "JParkinson1991 (229 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jparkinson1991-composer-linker-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/jparkinson1991-composer-linker-plugin/health.svg)](https://phpackages.com/packages/jparkinson1991-composer-linker-plugin)
```

###  Alternatives

[drupal/core-project-message

Adds a message after Composer installation.

2122.6M172](/packages/drupal-core-project-message)[vaimo/composer-changelogs

Provide information about package changes based on changelog files that are bundled with releases; provide tools for generating documentation files from changelog sources

11150.5k10](/packages/vaimo-composer-changelogs)[williarin/cook

Composer plugin to execute recipes embedded in packages

252.1k3](/packages/williarin-cook)[uma/composer-psysh

No-frills PsySH-Composer plugin

183.2k](/packages/uma-composer-psysh)[numero2/contao-storelocator

Contao Plugin for managing stores (or in common address data) and providing a frontend-search based on geo data

121.5k](/packages/numero2-contao-storelocator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
