Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions blog/2025-06-03-snail.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Snail
authors: [jannik]
tags: [snail]
---

We have new bundle for [snails].

Read more in the docs about what snails are and what they are used for.


[snails]: /docs/php/symfony/snail
59 changes: 59 additions & 0 deletions docs/php/symfony/snail/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {LinkList} from "../../../../src/components/Link/LinkList";

# Snail

<LinkList
github="https://github.com/21TORR/SnailBundle"
packagist="https://packagist.org/packages/21torr/snail"
/>

A bundle with helpers for using *snails*.

:::tip
A *snail* is a **slug** with a very specific format.
:::

The format of a snail is:

- only lower case latin letters (`[a-z]`)
- numbers (`[0-9]`)
- special characters: `. _ -`
- must not end or start on a special character
- no consecutive multiple special characters (so no `a-_b` allowed)


Snails are URL safe and safe to use on the CLI as key.


## Installation

Install the bundle:

```bash
composer require 21torr/snail
```

## Usage

### Validating a snail

```php
use Torr\Snail\Snail\Snailer;

Snailer::isValidSnail($string);
```


### Generating a snail

You can also generate a snail from any string.
Please note that consecutive special characters will be collapsed to the first special character (so `".-_." -> "."`).

The snailer also removes all not-allowed characters. If the result will be an empty string, a `SnailGenerationFailedException` will be thrown.

```php
use Torr\Snail\Snail\Snailer;

$snailer = new Snailer();
$snailer->generateSnail($string);
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ src/
│ ├─ Widget/
│ ├─ ComponentGroup.php
│ └─ ComponentTag.php
└ Field/
Field/
└─ Composite/
```

Expand Down