symfony-cmf/slugifier-api
Composer 安装命令:
composer require symfony-cmf/slugifier-api
包简介
Provides a basic slugifier interface to transform text into strings suitable for URLs
README 文档
README
This package is part of the Symfony Content Management Framework (CMF) and licensed under the MIT License.
A "slugifier" is a function which transforms a string such as this into a
URL-friendly string such-as-this. Slugifiers are also known as "urlizers".
This package does not contain a slugifier implementation, it provides a
standard interface (SlugifierInterface) for use by third party slugifiers
and a CallbackSlugifier that is capable of wrapping most non-implementing
third-party slugifiers to the SlugifierInterface.
Requirements
- See also the
requiresection of composer.json
Documentation
Perhaps the best way to document this simple component is with a demonstration. You have an event subscriber which slugifies the title of a blog post:
<?php use Symfony\Cmf\Api\Slugifier\SlugifierInterface; class FooSubscriber { private $slugifier; public function __construct(SlugifierInterface $slugifier) { $this->slugifier = $slugifier; } public function onEntitySave(\Some\Event $event) { $entity = $event->getEntity(); $entity->setSlug($this->slugifier->slugify($entity->getTitle()); } }
You can then inject either a slugifier which already implements the CMF
SlugifierInterface or you can use non-implementing libraries using the
CallbackSlugifier. Using non-implementing libraries is very easy, assume
you want to use the aferrandini/urlizer
package (which is also used by the RoutingAutoBundle),
you can configure the CallbackSlugifier object to call the Ferrandini\Urlizer::urlize()
method:
$slugifier = new CallbackSlugifier('Ferrandini\Urlizer::urlize'); $fooSubscriber = new FooSubscriber($slugifier);
By using the Slugifier package you decouple your application from the slugifier implementation.
See also:
- All Symfony CMF documentation - complete Symfony CMF reference
- Symfony CMF Website - introduction, live demo, support and community links
FIG Proposal
We proposed this to FIG but unfortunately the proposal did not get enough interest. We would still be happy to contribute this to a PSR should the interest come up and deprecate this package in favor of the PSR one.
Contributing
Pull requests are welcome. Please see our CONTRIBUTING guide.
Unit and/or functional tests exist for this bundle. See the Testing documentation for a guide to running the tests.
Thanks to everyone who has contributed already.
symfony-cmf/slugifier-api 适用场景与选型建议
symfony-cmf/slugifier-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.79M 次下载、GitHub Stars 达 28, 最近一次更新时间为 2016 年 01 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「slugify」 「urlize」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 symfony-cmf/slugifier-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 symfony-cmf/slugifier-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 symfony-cmf/slugifier-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Slugifier
A full-featured, simple, clean and pure functional implementation for creating slugs
Converts non-clickable URLs and email addresses in text (plain or HTML) into clickable HTML links
A Symfony2 Bundle to slugify swedish texts
Slug Generator
Simplest Slugify for PHP
统计信息
- 总下载量: 1.79M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 28
- 点击次数: 21
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-11