# EjectService

> Marks a file entry as ejected in scaffold-lock.json so scaffold stops writing it; the file stays on disk.

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

| final class | `PHPForge\Scaffold\Services\EjectService` |
| --- | --- |
| Source | [`src/Services/EjectService.php`](https://github.com/php-forge/scaffold/blob/main/src/Services/EjectService.php#L13) |

Marks a file entry as ejected in `scaffold-lock.json` so scaffold stops writing it; the file stays on disk.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`run()`](#method-run) | Marks the entry of `$file` as ejected, or only previews the change when `$confirmed` is `false`. | `EjectService` |

## Method details

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

```php
public function run(string $projectRoot, PHPForge\Scaffold\Console\OutputWriter $out, string $file, bool $confirmed = false): int
```

Marks the entry of `$file` as ejected, or only previews the change when `$confirmed` is `false`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$projectRoot` | `string` | Absolute path to the project root. |
| `$out` | [`PHPForge\Scaffold\Console\OutputWriter`](/docs/extensions/scaffold/reference/console/outputwriter/index.md) | Output sink. |
| `$file` | `string` | Destination path as recorded in `scaffold-lock.json`. |
| `$confirmed` | `bool` | Whether to write the ejection; `false` only previews it. |

**Returns**

`int`: `0` on success, including previews and entries already ejected; `1` when the entry is not tracked.

**Throws**

- [`RuntimeException`](https://www.php.net/manual/en/class.runtimeexception.php): when the lock file cannot be read or written.