承接 yic/sluggable-bundle 相关项目开发

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

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

yic/sluggable-bundle

最新稳定版本:v1.0.0

Composer 安装命令:

composer require yic/sluggable-bundle

包简介

A Symfony bundle for slug-based entity routing.

README 文档

README

License

A Symfony bundle that provides automatic slug generation and slug-based routing (ParamConverter resolution by ID or slug) for Doctrine entities implementing SluggableInterface.

✨Features

  • Generic SluggableInterface for entities
  • ParamConverter that works with both IDs and slugs
  • Automatic service registration
  • Works with Gedmo Sluggable behavior

🧩Installation

  1. Install the bundle via Composer:
composer require yic/sluggable-bundle

⚙️Basic Usage

Implement Sluggable

use YIC\SluggableBundle\Entity\Interface\SluggableInterface;
use Gedmo\Mapping\Annotation as Gedmo;

class Product implements SluggableInterface
{
    #[Gedmo\Slug(fields: ['title'])]
    private ?string $slug = null;

    public function getSlug(): ?string {
        return $this->slug;
    }

    public function setSlug(?string $slug): self {
        $this->slug = $slug;
        return $this;
    }
}

Use in controllers

#[Route('/products/{id}', name: 'product_show')]
public function show(Product $product): Response
{
    // Works with:
    // /products/1         (ID)
    // /products/some-name (slug)
}

Configuration

Default config (config/packages/yic_sluggable.yaml):

yic_sluggable:
    # Enable slug fallback when ID not found
    slug_fallback: true      

Development Setup

# Clone
git clone https://github.com/yaovicoder/sluggable-bundle.git
cd sluggable-bundle

# Install deps
composer install

# Run tests
composer test

📦 Dependencies

Core Requirements

| Package                          | Version   | Purpose                   |
|----------------------------------|-----------|---------------------------|
| php                              | ^8.1      | PHP runtime               |
| symfony/framework-bundle         | ^6.4      | Symfony core              |
| doctrine/orm                     | ^2.15     | Database abstraction      |
| gedmo/doctrine-extensions        | ^3.11     | Slug behavior             |
| sensio/framework-extra-bundle    | ^6.0      | ParamConverter            |

Development Dependencies

| Package                          | Version   | Purpose                   |
|----------------------------------|-----------|---------------------------|
| phpunit/phpunit                  | ^10.0     | Testing                   |
| symfony/phpunit-bridge           | ^6.4      | Symfony test integration  |
| vimeo/psalm                      | ^5.22     | Static analysis           |

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-02