# EventSubscriber

> Listens to Composer script events and triggers the scaffold workflow.

[API reference](/docs/api/index.md) › [Scaffold](/docs/extensions/scaffold/reference/index.md) › EventSubscriber

| final class | `PHPForge\Scaffold\EventSubscriber` |
| --- | --- |
| Implements | `Composer\EventDispatcher\EventSubscriberInterface` |
| Source | [`src/EventSubscriber.php`](https://github.com/php-forge/scaffold/blob/main/src/EventSubscriber.php#L23) |

Listens to Composer script events and triggers the scaffold workflow.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`getSubscribedEvents()`](#method-getSubscribedEvents) static | Returns the Composer script events handled by this subscriber. | `EventSubscriber` |
| [`onPostCreateProject()`](#method-onPostCreateProject) | Runs the scaffold workflow for `post-create-project-cmd`, unless `post-install-cmd` or `post-update-cmd` already fired in this process. | `EventSubscriber` |
| [`onPostInstall()`](#method-onPostInstall) | Runs the scaffold workflow for `post-install-cmd`. | `EventSubscriber` |
| [`onPostUpdate()`](#method-onPostUpdate) | Runs the scaffold workflow for `post-update-cmd`. | `EventSubscriber` |

## Method details

### getSubscribedEvents() <span id="method-getSubscribedEvents"></span>

```php
public static function getSubscribedEvents(): array<string, string>
```

Returns the Composer script events handled by this subscriber.

**Returns**

`array<string, string>`: Event name => handler method.

### onPostCreateProject() <span id="method-onPostCreateProject"></span>

```php
public function onPostCreateProject(Composer\Script\Event $event): void
```

Runs the scaffold workflow for `post-create-project-cmd`, unless `post-install-cmd` or `post-update-cmd` already
fired in this process.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$event` | `Composer\Script\Event` | The Composer event object. |

### onPostInstall() <span id="method-onPostInstall"></span>

```php
public function onPostInstall(Composer\Script\Event $event): void
```

Runs the scaffold workflow for `post-install-cmd`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$event` | `Composer\Script\Event` | The Composer event object. |

### onPostUpdate() <span id="method-onPostUpdate"></span>

```php
public function onPostUpdate(Composer\Script\Event $event): void
```

Runs the scaffold workflow for `post-update-cmd`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$event` | `Composer\Script\Event` | The Composer event object. |