承接 teariot/beautyslug 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

teariot/beautyslug

最新稳定版本:1.0.0

Composer 安装命令:

composer require teariot/beautyslug

包简介

Lightweight PHP library for generating random readable slugs.

README 文档

README

PHP Version License

BeautySlug is a lightweight, flexible PHP library for generating beautiful, readable slugs.

🚀 Installation

Install via Composer:

composer require teariot/beautyslug

⚡ Quick Usage

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:

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 file for more examples.

To run:

php examples/usage.php

📄 License

Released under the MIT License.

Built with ❤️ by Teariot

统计信息

  • 总下载量: 2.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-28