PHPackages                             evotodi/composer-downloads-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. evotodi/composer-downloads-plugin

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

evotodi/composer-downloads-plugin
=================================

Composer plugin for downloading additional files within any composer package.

v3.1.0(5y ago)051MITPHPPHP &gt;=5.6

Since Aug 22Pushed 5y agoCompare

[ Source](https://github.com/evotodi/composer-downloads-plugin)[ Packagist](https://packagist.org/packages/evotodi/composer-downloads-plugin)[ RSS](/packages/evotodi-composer-downloads-plugin/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (8)Used By (1)

Composer Downloads Plugin
=========================

[](#composer-downloads-plugin)

The "Downloads" plugin allows you to download extra files (`*.zip` or `*.tar.gz`) and extract them within your package.

This is an updated version of [lastcall/composer-extra-files](https://github.com/LastCallMedia/ComposerExtraFiles/). It adds integration tests, fixes some bugs, and makes a few other improvements. Some of the configuration options have changed, so it has been renamed to prevent it from conflicting in real-world usage.

Example
-------

[](#example)

Suppose you publish a PHP package `foo/bar` which relies on an external artifact `examplelib-0.1.zip`. Place this configuration in the `composer.json` for `foo/bar`:

```
{
  "name": "foo/bar",
  "require": {
    "civicrm/composer-downloads-plugin": "~2.1"
  },
  "extra": {
    "downloads": {
      "examplelib": {
        "url": "https://example.com/examplelib-0.1.zip",
        "path": "extern/examplelib",
        "ignore": ["test", "doc", ".*"]
      }
    }
  }
}
```

When a downstream user of `foo/bar` runs `composer install`, it will fetch and extract the zip file, creating `vendor/foo/bar/extern/examplelib`.

Suppose your download url for an archive does not include a file extension. Add the `type` and `ext` to the package section.

```
{
  "name": "foo/bar",
  "require": {
    "civicrm/composer-downloads-plugin": "~2.1"
  },
  "extra": {
    "downloads": {
      "examplelib": {
        "url": "https://example.com/examplelib-0.1?type=zip",
        "type": "archive",
        "ext": "zip",
        "path": "extern/examplelib",
        "ignore": ["test", "doc", ".*"]
      }
    }
  }
}
```

Evaluation
----------

[](#evaluation)

The primary strengths of `composer-downloads-plugin` are:

- **Simple**: It downloads a URL (ZIP/TAR file) and extracts it. It only needs to know two things: *what to download* (`url`) and *where to put it* (`path`). It runs as pure-PHP without any external dependencies.
- **Fast**: The logic does not require scanning, indexing, or mapping any large registries. The download system uses `composer`'s built-in cache.
- **Isolated**: As the author of a package `foo/bar`, you define the content under the `vendor/foo/bar` folder. When others use `foo/bar`, there is no need for special instructions, no root-level configuration, no interaction with other packages.

The "Downloads" plugin is only a download mechanism. Use it to *assimilate* an external resource as part of a `composer` package.

The "Downloads" plugin is **not** a *dependency management system*. There is no logic to scan registries, resolve transitive dependencies, identify version-conflicts, etc among diverse external resources. If you need that functionality, then you may want a *bridge* to integrate `composer` with an external dependency management tool. A few good bridges to consider:

- [Asset Packagist](https://asset-packagist.org/)
- [Composer Asset Plugin](https://github.com/fxpio/composer-asset-plugin)
- [Composer Bower Plugin](https://github.com/php-kit/composer-bower-plugin)
- [Foxy](https://github.com/fxpio/foxy)

Configuration: Properties
-------------------------

[](#configuration-properties)

The `extra.downloads` section contains a list of files to download. Each extra-file has a symbolic ID (e.g. `examplelib` above) and some mix of properties:

- `url`: The URL to fetch the content from.
- `path`: The releative path where content will be extracted.
- `type`: (*Optional*) Determines how the download is handled

    - `archive`: The `url` references a zip or tarball which should be extracted at the given `path`. (Default for URLs involving `*.zip`, `*.tar.gz`, or `*.tgz`.)
    - `file`: The `url` should be downloaded to the given `path`. (Default for all other URLs.)
    - `phar`: The `url` references a PHP executable which should be installed at the given `path`.
- `ext`: (*Optional*) Specifies the file extension for `type: archive`
- `ignore`: (*Optional*) A list of a files that should be omited from the extracted folder. (This supports a subset of `.gitignore` notation.)
- `version`: (*Optional*) A version number for the downloaded artifact. This has no functional impact on the lifecycle of the artifact, but it can affect the console output, and it can be optionally used as a variable when setting `url` or `path`.

Values in `url` and `path` support the following variables:

- `{$id}`: The symbolic identifier of the download. (In the introductory example, it would be `examplelib`.)
- `{$version}`: The displayed/simulated/pretty version number of the package.

Configuration: Defaults
-----------------------

[](#configuration-defaults)

You may set default properties for all downloads. Place them under `*`, as in:

```
{
  "extra": {
    "downloads": {
      "*": {
        "path": "bower_components/{$id}",
        "ignore": ["test", "tests", "doc", "docs"]
      },
      "jquery": {
        "url": "https://github.com/jquery/jquery-dist/archive/1.12.4.zip"
      },
      "jquery-ui": {
        "url": "https://github.com/components/jqueryui/archive/1.12.1.zip"
      }
    }
  }
}
```

This example will:

- Create `bower_components/jquery` (based on jQuery 1.12.4), minus any test/doc folders.
- Create `bower_components/jquery-ui` (based on jQueryUI 1.12.1), minus any test/doc folders.

Tips
----

[](#tips)

- In each downloaded folder, this plugin will create a small metadata folder (`.composer-downloads`) to track the origin of the current code. If you modify the `composer.json` to use a different URL, then it will re-download the file.
- Download each extra file to a distinct `path`. Don't try to download into overlapping paths. (*This has not been tested, but I expect downloads are not well-ordered, and you may find that updates require re-downloading.*)
- What should you do if you *normally* download the extra-file as `*.tar.gz` but sometimes (for local dev) need to grab bleeding edge content from somewhere else? Simply delete the autodownloaded folder and replace it with your own. `composer-downloads-plugin` will detect that conflict (by virtue of the absent `.composer-downloads`) and leave your code in place (until you choose to get rid of it). To switch back, you can simply delete the code and run `composer install` again.

Known Limitations
-----------------

[](#known-limitations)

If you use `downloads` in a root-project (or in symlinked dev repo), it will create+update downloads, but it will not remove orphaned items automatically. This could be addressed by doing a file-scan for `.composer-downloads` (and deleting any orphan folders). Since the edge-case is not particularly common right now, and since a file-scan could be time-consuming, it might make sense as a separate subcommand.

I believe the limitation does *not* affect downstream consumers of a dependency. In that case, the regular `composer` install/update/removal mechanics should take care of any nested downloads.

Automated Tests
---------------

[](#automated-tests)

The `tests/` folder includes unit-tests and integration-tests written with PHPUnit. Each integration-test generates a new folder/project with a plausible, representative `composer.json` file and executes `composer install`. It checks the output has the expected files.

To run the tests, you will need `composer` and `phpunit` in the `PATH`.

```
[~/src/composer-downloads-plugin] which composer
/Users/myuser/bin/composer

[~/src/composer-downloads-plugin] which phpunit
/Users/myuser/bin/phpunit

[~/src/composer-downloads-plugin] phpunit
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.

.....                                                               5 / 5 (100%)

Time: 40.35 seconds, Memory: 10.00MB

OK (5 tests, 7 assertions)

```

The integration tests can be a bit large/slow. To monitor the tests more closesly, set the `DEBUG` variable, as in:

```
[~/src/composer-downloads-plugin] env DEBUG=2 phpunit

```

Local Dev Harness
-----------------

[](#local-dev-harness)

What if you want to produce an environment which uses the current plugin code - one where you can quickly re-run `composer` commands while iterating on code?

You may use any of the integration-tests to initialize a baseline environment:

```
env USE_TEST_PROJECT=$HOME/src/myprj DEBUG=2 phpunit tests/SniffTest.php

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 65.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 ~124 days

Recently: every ~154 days

Total

6

Last Release

1829d ago

Major Versions

v2.1.1 → v3.0.02020-11-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca420a42154e1ff8d69578fa18441e8e1f1943246e4607e065f237b31d9d349c?d=identicon)[evotodi](/maintainers/evotodi)

---

Top Contributors

[![totten](https://avatars.githubusercontent.com/u/1336047?v=4)](https://github.com/totten "totten (44 commits)")[![rbayliss](https://avatars.githubusercontent.com/u/654407?v=4)](https://github.com/rbayliss "rbayliss (11 commits)")[![mglaman](https://avatars.githubusercontent.com/u/3698644?v=4)](https://github.com/mglaman "mglaman (6 commits)")[![evotodi](https://avatars.githubusercontent.com/u/1625853?v=4)](https://github.com/evotodi "evotodi (3 commits)")[![seamuslee001](https://avatars.githubusercontent.com/u/6799125?v=4)](https://github.com/seamuslee001 "seamuslee001 (3 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/evotodi-composer-downloads-plugin/health.svg)

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

###  Alternatives

[vaimo/composer-patches

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. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M14](/packages/vaimo-composer-patches)[mglaman/composer-drupal-lenient

1317.4M15](/packages/mglaman-composer-drupal-lenient)[drupal/core-composer-scaffold

A flexible Composer project scaffold builder.

5341.9M441](/packages/drupal-core-composer-scaffold)[drupal/core-project-message

Adds a message after Composer installation.

2122.6M172](/packages/drupal-core-project-message)[olvlvl/composer-attribute-collector

A convenient and near zero-cost way to retrieve targets of PHP 8 attributes

184108.8k8](/packages/olvlvl-composer-attribute-collector)[lullabot/drainpipe

An automated build tool to allow projects to have a set standardized operations scripts.

41716.4k2](/packages/lullabot-drainpipe)

PHPackages © 2026

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