1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Removed scripts documentation duplication, refactor to the dedicated article page

This commit is contained in:
Romain Neutron 2012-03-27 00:59:08 +02:00
parent 9f331a2192
commit 6844d7b572
2 changed files with 14 additions and 57 deletions

View file

@ -40,24 +40,33 @@ Script definition example:
{
"scripts": {
"post-update-cmd": "MyVendor\\MyClass::postUpdate",
"post-package-install": ["MyVendor\\MyClass::postPackageInstall"]
"post-package-install": [
"MyVendor\\MyClass::postPackageInstall"
]
}
}
Script listener example:
The event handler receives a `Composer\Script\Event` object as an argument,
which gives you access to the `Composer\Composer` instance through the
`getComposer` method.
Using the previous example, here's an event listener example :
<?php
namespace MyVendor;
use Composer\Script\Event;
class MyClass
{
public static function postUpdate($event)
public static function postUpdate(Event $event)
{
$composer = $event->getComposer();
// do stuff
}
public static function postPackageInstall($event)
public static function postPackageInstall(Event $event)
{
$installedPackage = $event->getOperation()->getPackage();
// do stuff