# SymfonyOutputWriter

> Writes service messages to a Symfony Console output in raw mode, so stub content such as <?php ?> is never parsed as style tags.

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

| final readonly class | `PHPForge\Scaffold\Console\SymfonyOutputWriter` |
| --- | --- |
| Implements | [`OutputWriter`](/docs/extensions/scaffold/reference/console/outputwriter/index.md) |
| Source | [`src/Console/SymfonyOutputWriter.php`](https://github.com/php-forge/scaffold/blob/main/src/Console/SymfonyOutputWriter.php#L13) |

Writes service messages to a Symfony Console output in raw mode, so stub content such as `<?php ?>` is never parsed
as style tags.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a writer for a Symfony Console output. | `SymfonyOutputWriter` |
| [`isDecorated()`](#method-isDecorated) | Returns whether the console output supports ANSI decoration. | `SymfonyOutputWriter` |
| [`writeStderr()`](#method-writeStderr) | Writes `$message` and a newline to the error output, or to the main output when no error output is available. | `SymfonyOutputWriter` |
| [`writeStdout()`](#method-writeStdout) | Writes `$message` and a newline to the main output. | `SymfonyOutputWriter` |

## Method details

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

```php
public function __construct(Symfony\Component\Console\Output\OutputInterface $output)
```

Creates a writer for a Symfony Console output.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$output` | `Symfony\Component\Console\Output\OutputInterface` | Console output that receives the messages and, through its error output when it is a [`ConsoleOutputInterface`](https://github.com/symfony/console/blob/21f1bc2296f7ff6043241a8dcbc09559b3732820/Output/ConsoleOutputInterface.php#L20), the standard error messages. |

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

```php
public function isDecorated(): bool
```

Returns whether the console output supports ANSI decoration.

**Returns**

`bool`: `true` when the main output is decorated, `false` otherwise.

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

```php
public function writeStderr(string $message): void
```

Writes `$message` and a newline to the error output, or to the main output when no error output is available.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$message` | `string` | Message without a trailing newline; the writer appends one. |

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

```php
public function writeStdout(string $message): void
```

Writes `$message` and a newline to the main output.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$message` | `string` | Message without a trailing newline; the writer appends one. |