Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Composer installs packages into a single vendor directory. Some projects however require a more complex deployment strategy. This plugin allows to move or symlink individual package files into specified directories.

License

Notifications You must be signed in to change notification settings

pickware/composer-merge-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

composer-merge-plugin

This free and open source MIT-licensed Composer plugin allows you to move or symlink individual package files into specified directories outside the vendor directory.

Some projects have specific requirements on the location of package files that cannot be resolved by the Composer autoloader. This often concerns resource files such as html, css or language files. Legacy projects might need to include php files from specific locations outside the vendor directory.

Examples:

  • A web project might require html and css resources to be moved to global /html and /css folders
  • An international project expects all language files to reside within a global /languages directory

Instead of relying on a build system or generic task runner such as brunch, gulp or grunt on top of Composer to perform these deployment tasks, this plugin aims at extending the capabilities of Composer to perform such build automation.

Usage

  1. This plugin is not published on Packagist yet. To add it to your Composer-based project, add the corresponding repository for it to your composer.json. Composer's documentation describes how to work with repositories.

  2. Add the plugin to your composer.json as a dependency:

    "require": {
        "viison/composer-merge-plugin": "*",
        ...
    }
  3. Configure the merge-plugin via your composer.json:

    "extra": {
        "merge-plugin": {
            "some/example-package": {
                "merge-patterns": [
                    {
                        "src": "~assets/css/([^/]+)~",
                        "dst": "css/\\1"
                    }
                ],
                "merge-strategy": "copy"
            }
        }
    }

    This example configuration will copy all files from root-package/vendor/some/example-package/assets/css to root-package/assets/css

Merge pattens

A merge pattern is a regular expression matching paths within your specified package. Matching files and directories will then be symlinked or copied into your root package directory.

You can either give a single regular expression or spefify an src pattern and a dst replacement.

Merge strategies

The merge plugin can either symlink or copy your package's files, depending on your chosen merge-strategy.

You can also specify merge-strategy-dev which will take precedence over merge-strategy.

Examples

  1. Copy all files from root-package/vendor/some/example-package/assets/css to root-package/assets/css

    "extra": {
        "merge-plugin": {
           "some/example-package": {
               "merge-patterns": [
                  "~assets/css/([^/]+)~"
                ],
               "merge-strategy": "copy"
            }
        }
    }
  2. Symlink all files from root-package/vendor/some/example-package/assets/css to root-package/public/css

    "extra": {
        "merge-plugin": {
            "some/example-package": {
              	"merge-patterns": [
                    {
                        "src": "~assets/css/([^/]+)~",
                        "dst": "public/css/\\1"
                    }
                ],
                "merge-strategy": "symlink"
            }
        }
    }

License

composer-merge-plugin is licensed under the MIT License - see the LICENSE file for details.

Copyright 2016 VIISON GmbH https://viison.com/

About

Composer installs packages into a single vendor directory. Some projects however require a more complex deployment strategy. This plugin allows to move or symlink individual package files into specified directories.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages