PHPackages                             werbfred/composer-package-updater - 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. werbfred/composer-package-updater

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

werbfred/composer-package-updater
=================================

This project provides a way to have scripts be executed on packages when they are being installed, updated and uninstalled.

1.0.2(5y ago)21.2k2MITPHPPHP &gt;=7.0.0

Since Nov 21Pushed 5y ago1 watchersCompare

[ Source](https://github.com/werbfred/composer-package-updater)[ Packagist](https://packagist.org/packages/werbfred/composer-package-updater)[ Docs](https://github.com/werbfred/composer-package-update)[ RSS](/packages/werbfred-composer-package-updater/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Composer Package Updater
========================

[](#composer-package-updater)

This project provides a way to have scripts be executed on packages when they are being installed, updated and uninstalled.

Currently only scripts defined in the root ***composer.json*** file are being executed. This is a workaround to Composer's [Issue 1993](https://github.com/composer/composer/issues/1193).

For security reasons, ***Composer\\Script\\PackageEvent*** will only be forwarded to the packages for which these events are being raised.

In my case, I have Drupal modules and themes hosted in a git repo. Once installed/updated via composer I want to:

- Run ***compass*** to generate .css files
- Remove some files (.gitignore, .sass directory, ...)

Each module or theme being responsible to perform its own install/update/uninstall tasks.

Setting it up !
---------------

[](#setting-it-up-)

Install this project via packagist :

```
composer require werbfred/composer-package-updater

```

Open the root ***composer.json*** file to update it with configuration below:

### Autoload

[](#autoload)

Add `"ComposerPackageUpdater\\composer\\": "vendor/werbfred/composer-package-updater/src/composer"` to `psr-4` in `autoload` section.

#### Example:

[](#example)

```
"autoload": {
   "psr-4": {
      "ComposerPackageUpdater\\composer\\": "vendor/werbfred/composer-package-updater/src/composer"
   }
}

```

This will tell Composer where files of a given namespace are located. In our case Composer will be able to load our ***PackageUpdater*** class.

***Note***: More information on `autoload` section can be found [here](https://getcomposer.org/doc/04-schema.md#autoload).

### Scripts

[](#scripts)

Add below entries to the `scripts` section.

```
"scripts": {
   "pre-package-install": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
   "post-package-install": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
   "pre-package-update": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
   "post-package-update": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
   "pre-package-uninstall": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
   "post-package-uninstall": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent"
}

```

The above will ensure that below ***PackageEvents*** can be forwarded :

- pre-package-install
- post-package-install
- pre-package-update
- post-package-update
- pre-package-uninstall
- post-package-uninstall

***Note***: More information on `scripts` section can be found [here](https://getcomposer.org/doc/articles/scripts.md) and [there](https://getcomposer.org/doc/04-schema.md#scripts).

### Configuration

[](#configuration)

Configuration must be added under `dependency-scripts` in `extra` section.

#### Parameters:

[](#parameters)

ParametertypeDefaultDescriptionrunboolfalseIf ***true*** package scripts will be called. Any other value will be considered as ***false***.trustarray\[\]List of packages for which you want the ***Composer\\Script\\PackageEvent*** be dispatched.#### Example:

[](#example-1)

```
"extra": {
   "dependency-scripts": {
      "run": true,
      "trust": [ "dummy"
               , "foobar" ]
   }
}

```

***Note***: More information on `extra` section can be found [here](https://getcomposer.org/doc/04-schema.md#extra).

What do I need to put in my package's **composer.json\*** file ?
----------------------------------------------------------------

[](#what-do-i-need-to-put-in-my-packages-composerjson-file-)

You can now fill your `scripts` section with your own ones.

***Be careful***: Pathes in your `autoloads` section must be relative to your package's location.

Usefull Links
-------------

[](#usefull-links)

- Composer.json schema : https://getcomposer.org/doc/04-schema.md
- More on scripts : https://getcomposer.org/doc/articles/scripts.md

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~108 days

Total

3

Last Release

2152d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/833b1479ec2e5d2c211a0d9b99852f1a09868ee25465bcf3c778be8e464a2642?d=identicon)[werbfred](/maintainers/werbfred)

---

Top Contributors

[![werbfred](https://avatars.githubusercontent.com/u/30314952?v=4)](https://github.com/werbfred "werbfred (6 commits)")[![cavasinf](https://avatars.githubusercontent.com/u/25293190?v=4)](https://github.com/cavasinf "cavasinf (2 commits)")

---

Tags

phpcomposerpackage

### Embed Badge

![Health badge](/badges/werbfred-composer-package-updater/health.svg)

```
[![Health](https://phpackages.com/badges/werbfred-composer-package-updater/health.svg)](https://phpackages.com/packages/werbfred-composer-package-updater)
```

###  Alternatives

[netojose/laravel-bootstrap-4-forms

Bootstrap 4 form builder for Laravel 5

182115.3k](/packages/netojose-laravel-bootstrap-4-forms)[camcima/php-geohash

Refactored GeoHash package

1074.0k](/packages/camcima-php-geohash)

PHPackages © 2026

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