PHP Classes

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2023-09-09 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 33 All time: 10,889 This week: 117Up
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: 33 packages by
Country: Russian Federation Russian Federation
Age: 34
All time rank: 308584 in Russian Federation Russian Federation
Week rank: 3 Up1 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 15x

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  
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  /  src  
File Role Description
  Plain text file HookManager.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:33
This week:0
All time:10,889
This week:117Up