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:
parent
9f331a2192
commit
6844d7b572
2 changed files with 14 additions and 57 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue