zenstruck/slugify-bundle

该软件包已被弃用,不再维护。作者建议使用cocur/slugify软件包。

提供slugify服务和twig过滤器,用于Symfony2。

资助软件包维护!
kbond

安装数量: 44,020

依赖项: 1

建议者: 3

安全: 0

星标: 7

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

v1.1.1 2013-12-11 15:33 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:24:34 UTC


README

已弃用,推荐使用cocur/slugify,该软件包现在包括Symfony2 Bundle

此软件包提供了将Slugify库集成到Symfony2中的功能。提供slugify服务和twig过滤器。

安装

  1. 使用composer安装

    php composer.phar require zenstruck/slugify-bundle
    
  2. 启用软件包

    // app/AppKernel.php
    
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Zenstruck\SlugifyBundle\ZenstruckSlugifyBundle()
        );
    }

使用服务

/** @var Cocur\Slugify\Slugify $slugify */
$slugify = $this->container->get('zenstruck.slugify');

使用Twig过滤器

{{ 'Hello World!'|slugify }} {# hello-world #}

{# custom space separator #}
{{ 'Hello World!'|slugify('_') }} {# hello_world #}

{# custom space separator and custom replacement for emptyValue #}
{{ '####'|slugify('_', 'non') }} {# non #}

完整的默认配置

zenstruck_slugify:
    twig: true #enable twig filter
    mode: array #iconv or array mode