# Code Snippet

HTML: [altophp.com/code-snippet](https://altophp.com/code-snippet/)

Code Snippet stores code, original line numbers, selections, and annotations as
immutable values. Use it to pass an excerpt between extraction, analysis, and
presentation without tying the data to a renderer.

```php
use Alto\Code\Snippet\CodeSnippet;

$snippet = CodeSnippet::fromCode("first\nsecond\nthird", 'php', startLine: 24)
    ->selectLines(3);

echo $snippet->lines()[2]->number; // 26
```

## Documentation

- [Installation](https://altophp.com/code-snippet/installation.md): install the package and verify it can create a snippet.
- [Getting started](https://altophp.com/code-snippet/getting-started.md): create a snippet and inspect a selected line.
- [Usage](https://altophp.com/code-snippet/usage.md): work with snippets, lines, annotations, segments, and transformations.

The package owns the portable snippet model. It does not read files, detect
languages, locate declarations, tokenize code, or render output.

---

Next: [Installation](https://altophp.com/code-snippet/installation.md)

---

ALTO\CODE SNIPPET: [altophp.com/code-snippet](https://altophp.com/code-snippet/)
ALTO(PHP): [altophp.com](https://altophp.com/)
