Skip to content

Commit 3bb406b

Browse files
authored
Merge pull request #57 from 21TORR/snail
Snail 🐌
2 parents 5d42a7f + 10c24a4 commit 3bb406b

3 files changed

Lines changed: 72 additions & 1 deletion

File tree

β€Žblog/2025-06-03-snail.mdxβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Snail
3+
authors: [jannik]
4+
tags: [snail]
5+
---
6+
7+
We have new bundle for [snails].
8+
9+
Read more in the docs about what snails are and what they are used for.
10+
11+
12+
[snails]: /docs/php/symfony/snail
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import {LinkList} from "../../../../src/components/Link/LinkList";
2+
3+
# Snail
4+
5+
<LinkList
6+
github="https://github.com/21TORR/SnailBundle"
7+
packagist="https://packagist.org/packages/21torr/snail"
8+
/>
9+
10+
A bundle with helpers for using *snails*.
11+
12+
:::tip
13+
A *snail* is a **slug** with a very specific format.
14+
:::
15+
16+
The format of a snail is:
17+
18+
- only lower case latin letters (`[a-z]`)
19+
- numbers (`[0-9]`)
20+
- special characters: `. _ -`
21+
- must not end or start on a special character
22+
- no consecutive multiple special characters (so no `a-_b` allowed)
23+
24+
25+
Snails are URL safe and safe to use on the CLI as key.
26+
27+
28+
## Installation
29+
30+
Install the bundle:
31+
32+
```bash
33+
composer require 21torr/snail
34+
```
35+
36+
## Usage
37+
38+
### Validating a snail
39+
40+
```php
41+
use Torr\Snail\Snail\Snailer;
42+
43+
Snailer::isValidSnail($string);
44+
```
45+
46+
47+
### Generating a snail
48+
49+
You can also generate a snail from any string.
50+
Please note that consecutive special characters will be collapsed to the first special character (so `".-_." -> "."`).
51+
52+
The snailer also removes all not-allowed characters. If the result will be an empty string, a `SnailGenerationFailedException` will be thrown.
53+
54+
```php
55+
use Torr\Snail\Snail\Snailer;
56+
57+
$snailer = new Snailer();
58+
$snailer->generateSnail($string);
59+
```

β€Ždocs/php/symfony/storyblok/components/recommended-directory-structure.mdxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ src/
1515
β”‚ β”œβ”€ Widget/
1616
β”‚ β”œβ”€ ComponentGroup.php
1717
β”‚ └─ ComponentTag.php
18-
β”” Field/
18+
└─ Field/
1919
└─ Composite/
2020
```
2121

0 commit comments

Comments
Β (0)