https://github.com/teariot/beautyslug
Lightweight PHP library for generating random readable slugs.
https://github.com/teariot/beautyslug
cms-friendly-slug composer friendly-url laravel-slug php php-slug random-slug seo seo-friendly-slug seo-url slug-generator slugify unique-slug url-identifier url-slug
Last synced: 5 months ago
JSON representation
Lightweight PHP library for generating random readable slugs.
- Host: GitHub
- URL: https://github.com/teariot/beautyslug
- Owner: TeaRiot
- License: mit
- Created: 2025-04-28T22:59:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-28T23:00:03.000Z (about 1 year ago)
- Last Synced: 2025-12-29T06:35:37.605Z (7 months ago)
- Topics: cms-friendly-slug, composer, friendly-url, laravel-slug, php, php-slug, random-slug, seo, seo-friendly-slug, seo-url, slug-generator, slugify, unique-slug, url-identifier, url-slug
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BeautySlug
[](https://www.php.net/)
[](LICENSE)
**BeautySlug** is a lightweight, flexible PHP library for generating beautiful, readable slugs.
---
## 🚀 Installation
Install via Composer:
```bash
composer require teariot/beautyslug
```
---
## ⚡ Quick Usage
```php
use BeautySlug\BeautySlug;
use BeautySlug\SlugWords;
// Basic random slug
echo BeautySlug::slug();
// Example: wonderful-tree
// Slug with a color and an animal
echo BeautySlug::slug([
SlugWords::color(1),
SlugWords::animal(1),
]);
// Example: blue-lion
// Slug with digits appended
echo BeautySlug::slug([
SlugWords::adjective(1),
SlugWords::noun(1),
], [
'appendDigits' => true,
'digitsCount' => 5,
]);
// Example: fancy-robot-48291
```
---
## ⚙️ Options
| Option | Type | Description | Default |
|----------------|----------|----------------------------------------------|---------|
| `separator` | `string` | Separator between words | `-` |
| `appendDigits` | `bool` | Append random digits at the end | `false` |
| `digitsCount` | `int` | Number of digits to append if enabled | `4` |
You can override options by passing an array as the second parameter to `slug()`.
---
## 🧩 Available Word Categories
BeautySlug uses predefined word lists:
- `adjective`
- `noun`
- `color`
- `season`
- `emoji`
- `verb`
- `animal`
- `cosmos`
You can directly access random words:
```php
SlugWords::adjective(2); // Get 2 random adjectives
SlugWords::noun(1); // Get 1 random noun
SlugWords::color(1); // Get 1 random color
```
---
## 📂 Example Script
See the [`examples/usage.php`](examples/usage.php) file for more examples.
To run:
```bash
php examples/usage.php
```
---
## 📄 License
Released under the [MIT License](LICENSE).
---
> Built with ❤️ by [Teariot](https://github.com/teariot)