定制 voku/urlify 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

voku/urlify

Composer 安装命令:

composer require voku/urlify

包简介

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

README 文档

README

CI Coverage Status Codacy Badge Latest Stable Version Total Downloads License Donate to this project using Paypal Donate to this project using Patreon

🔗 URLify

Description

Convert any string into an valid and readable string for usage in the url.

This is a PHP port of "URLify.js" from the Django project + fallback via "Portable ASCII". We handles symbols from many languages via an matching-array and others via "ASCII::to_transliterate()".

Install via "composer require"

composer require voku/urlify

Usage:

namespace: "voku\helper\URLify"

To generate slugs for URLs:

echo URLify::filter(' J\'étudie le français ');
// "J-etudie-le-francais"

echo URLify::filter('Lo siento, no hablo español.');
// "Lo-siento-no-hablo-espanol"

To generate slugs for file names:

echo URLify::filter('фото.jpg', 60, '', true);
// "foto.jpg"

To simply transliterate characters:

echo URLify::downcode('J\'étudie le français');
// "J'etudie le francais"

echo URLify::downcode('Lo siento, no hablo español.');
// "Lo siento, no hablo espanol."

/* Or use transliterate() alias: */

echo URLify::transliterate('Lo siento, no hablo español.');
// "Lo siento, no hablo espanol."

To extend the character list:

URLify::add_chars(array(
  '¿' => '?', '®' => '(r)', '¼' => '1/4',
  '½' => '1/2', '¾' => '3/4', '' => 'P'
));

echo URLify::downcode('¿ ® ½ ¼ ¾ ¶');
// "? (r) 1/2 1/4 3/4 P"

To extend or replace the default replacing list:

URLify::add_array_to_seperator(array(
  "/®/"
));

echo URLify::filter('¿ ® ½ ¼ ¾ ¶');
// "12-14-34-P"

To extend the list of words to remove for one language:

URLify::remove_words(array('remove', 'these', 'too'), 'de');

To prioritize a certain language map:

echo URLify::filter(' Ägypten und Österreich besitzen wie üblich ein Übermaß an ähnlich öligen Attachés ', 60, 'de');
// "Aegypten-und-Oesterreich-besitzen-wie-ueblich-ein-Uebermass-aehnlich-oeligen-Attaches"
   
echo URLify::filter('Cağaloğlu, çalıştığı, müjde, lazım, mahkûm', 60, 'tr');
// "Cagaloglu-calistigi-mujde-lazim-mahkum"

Please note that the "ü" is transliterated to "ue" in the first case, whereas it results in a simple "u" in the latter.

Available languages

  • Arabic: 'ar'
  • Austrian (German): 'de_at'
  • Austrian (French): 'fr_at'
  • Azerbaijani: 'az'
  • Bulgarian: 'bg'
  • Burmese: 'by'
  • Croatian: 'hr'
  • Czech: 'cs'
  • Danish: 'da'
  • English: 'en'
  • Esperanto: 'eo'
  • Estonian: 'et'
  • Finnish: 'fi'
  • French: 'fr'
  • Georgian: 'ka'
  • German: 'de'
  • Greek: 'el'
  • Hindi: 'hi'
  • Hungarian: 'hu'
  • Kazakh: 'kk'
  • Latvian: 'lv'
  • Lithuanian: 'lt'
  • Norwegian: 'no'
  • Polish: 'pl'
  • Romanian: 'ro'
  • Russian: 'ru'
  • Serbian: 'sr'
  • Slovak: 'sk'
  • Swedish: 'sv'
  • Switzerland (German): 'de_ch'
  • Switzerland (French): 'fr_ch'
  • Turkish: 'tr'
  • Ukrainian: 'uk'
  • Vietnamese: 'vn'

Support

For support and donations please visit Github | Issues | PayPal | Patreon.

For status updates and release announcements please visit Releases | Twitter | Patreon.

For professional support please contact me.

Thanks

  • Thanks to GitHub (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
  • Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
  • Thanks to GitHub Actions for providing the CI pipeline for this project!
  • Thanks to StyleCI for the simple but powerful code style check.
  • Thanks to PHPStan && Psalm for really great Static analysis tools and for discovering bugs in the code!

voku/urlify 适用场景与选型建议

voku/urlify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.19M 次下载、GitHub Stars 达 25, 最近一次更新时间为 2014 年 01 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「url」 「link」 「slug」 「encode」 「urlify」 「transliterate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 voku/urlify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 voku/urlify 我们能提供哪些服务?
定制开发 / 二次开发

基于 voku/urlify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.19M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 37
  • 依赖项目数: 7
  • 推荐数: 0

GitHub 信息

  • Stars: 25
  • Watchers: 3
  • Forks: 75
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-01-01