# SyncService

> Applies the allowed and installed providers to the project from the command line, with the same rules as a Composer install or update, or previews what applying them would change.

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

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

Applies the allowed and installed providers to the project from the command line, with the same rules as a
Composer `install` or `update`, or previews what applying them would change.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`run()`](#method-run) | Synchronizes the project with its providers and ends with a summary line; works with `auto: false` and creates `scaffold-lock.json` when it is missing. | `SyncService` |

## Method details

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

```php
public function run(PHPForge\Scaffold\Config\ProjectContext $context, PHPForge\Scaffold\Console\OutputWriter $out, bool $dryRun = false, bool $exitCode = false, bool $force = false, bool $decorated = false): int
```

Synchronizes the project with its providers and ends with a summary line; works with `auto: false` and
creates `scaffold-lock.json` when it is missing.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$context` | [`PHPForge\Scaffold\Config\ProjectContext`](/docs/extensions/scaffold/reference/config/projectcontext/index.md) | Project to synchronize. |
| `$out` | [`PHPForge\Scaffold\Console\OutputWriter`](/docs/extensions/scaffold/reference/console/outputwriter/index.md) | Output sink. |
| `$dryRun` | `bool` | Whether to print what applying the providers would change instead of writing anything. |
| `$exitCode` | `bool` | Whether a dry run returns `1` when applying would write a file or record a new entry. |
| `$force` | `bool` | Whether to overwrite user-modified and adopted `replace` files, like `reapply --force`. |
| `$decorated` | `bool` | Whether a dry run colors its diffs. |

**Returns**

`int`: `1` when a provider manifest cannot be loaded, a file fails to apply or the lock cannot be written, or with `$dryRun` and `$exitCode` when applying would change something; `0` otherwise.

**Throws**

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