PHP Classes

PHP Composer Install Mushroom Hook Manager: Run Composer package post-installation scripts

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 37 All time: 10,956 This week: 104Up
Version License PHP version Categories
mushroom-hook-manage 1.0MIT/X Consortium ...7Tools, PHP 7
Description 

Author

This package can run Composer package post-installation scripts.

It provides a plugin class that can register hook functions that will be executed after a package is installed or updated with PHP Composer.

Applications that want to customize the actions performed after installing or updating a package with PHP Composer can use the MushroomHooks class to execute custom code to implement those actions.

Innovation Award
PHP Programming Innovation award nominee
September 2023
Number 6
PHP Composer is a popular tool that can install PHP packages and other dependency packages.

When a package is installed or updated, Composer can call the registered hook functions to perform any actions specific to the installed package or project.

This package can register hook functions that can be called after the installation or the package update.

Projects that use this package can configure the installation of those projects by defining in the composer.json configuration file which classes of their project will perform custom actions after the projects are installed or updated.

Manuel Lemos
Picture of Smoren  Freelight
  Performance   Level  
Name: Smoren Freelight <contact>
Classes: 38 packages by
Country: Russian Federation Russian Federation
Age: 35
All time rank: 280778 in Russian Federation Russian Federation
Week rank: 10 Up1 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 16x

Documentation

Mushroom Hook Manager

Composer plugin for running post-install/post-update scripts of your project's dependencies

Using in your package

Possible example:

Create file MushroomHooks.php in the root of you package source directory with such content:

<?php

namespace Your\Package\Namespace;

class MushroomHooks
{
    public static function afterInstall($params)
    {
        // some actions on after install your package...
    }

    public static function afterUpdate($params)
    {
        // some actions on after update your package...
    }
}

Next add this lines to your package's composer.json file:

...
"require": {
    "smoren/mushroom-hook-manager": "1.0.0",
    ...
},
...
"extra": {
    ...
    "mushroom-use-hooks": true,
    "mushroom-hooks": {
        "after-install": [
            "Your\\Package\\Namespace\\MushroomHooks::afterInstall"
        ],
        "after-update": [
            "Your\\Package\\Namespace\\MushroomHooks::afterUpdate"
        ]
    }
}
...

You can also pass some params to package's hooks in your project (as arguments for methods afterInstall and afterUpdate).

Example for your project'scomposer.json file:

...
"extra": {
    ...
    "mushroom-hooks-params": {
        "your-composer/package-name": {
            "after-install": {
                "some-param": 1,
                "another-param": 2
            },
            "after-update": {
                "foo": "bar"
            }
        }
    }
}
...

  Files folder image Files (4)  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files (4)  /  src  
File Role Description
  Plain text file HookManager.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:37
This week:0
All time:10,956
This week:104Up