cetver/yii2-language-url-manager
Composer 安装命令:
composer require cetver/yii2-language-url-manager
包简介
Parses and creates URLs containing languages for the Yii framework 2.0
README 文档
README
Parses and creates URLs containing languages
Installation
The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist cetver/yii2-language-url-manager
or add
"cetver/yii2-language-url-manager": "^1.0"
to the require section of your composer.json file.
Usage
Update the web-application configuration file
return [ 'components' => [ 'urlManager' => [ 'class' => 'cetver\LanguageUrlManager\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, /* * The list of available languages. */ 'languages' => ['en', 'ru'], /* or 'languages' => function () { return \app\models\Language::find()->select('code')->column(); }, */ /* * - true: processes the URL like "en.example.com" * - false: processes the URL like "example.com/en" * NOTE: If this property set to true, the domain containing a language, must be the first on the left side, * for example: * - en.it.example.com - is valid * - it.en.example.com - is invalid */ 'existsLanguageSubdomain' => false, /* * The regular expression patterns list, applied to path info, if there are matches, the request, * containing a language, will not be processed. * For performance reasons, the blacklist does not applied for URL creation (Take a look at an example). * @see \yii\web\Request::getPathInfo() * An example: * ```php * [ * '/^api.*$/' * ] * ``` * - Requesting the blacklisted URL * - $existsLanguageSubdomain = true * - en.example.com/api (404 Not Found) * - en.example.com/api/create (404 Not Found) * - $existsLanguageSubdomain = false * - example.com/en/api (404 Not Found) * - example.com/en/api/create (404 Not Found) * - Creating the blacklisted URL * - echo \yii\helpers\Html::a('API', ['api/index', Yii::$app->urlManager->queryParam => null]); */ 'blacklist' => [], /* * The query parameter name that contains a language. */ 'queryParam' => 'language' ], ] ];
Tests
Run the following commands
composer create-project --prefer-source cetver/yii2-language-url-manager
cd yii2-language-url-manager
vendor/bin/codecept run unit
For I18N support, take a look at
- https://github.com/cetver/yii2-languages-dispatcher - Sets the web-application language
- https://github.com/cetver/yii2-language-url-manager - Parses and creates URLs containing languages
- https://github.com/cetver/yii2-language-selector - Provides the configuration for the language selector
- https://github.com/creocoder/yii2-translateable - The translatable behavior (Active Record)
cetver/yii2-language-url-manager 适用场景与选型建议
cetver/yii2-language-url-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 121.49k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2017 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「i18n」 「url」 「locale」 「extension」 「language」 「parse」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cetver/yii2-language-url-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cetver/yii2-language-url-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cetver/yii2-language-url-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use i18n translation PHP class for multi-language websites
Package for convenient work with Laravel's localization features
A custom URL rule class for Yii 2 which allows to create translated URL rules
Easy URL rewrites in your Laravel application
Bureaux A Partager Edit - Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Nette Framework adapter for I18n package
统计信息
- 总下载量: 121.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-07-19