Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skeeks-semenov/yii2-slug-behavior
Yii2 slug behavior (Semantic URL)
https://github.com/skeeks-semenov/yii2-slug-behavior
behavior skeeks slug sluggable slugify yii yii2 yii2-behavior yii2-extension
Last synced: 3 months ago
JSON representation
Yii2 slug behavior (Semantic URL)
- Host: GitHub
- URL: https://github.com/skeeks-semenov/yii2-slug-behavior
- Owner: skeeks-semenov
- License: bsd-3-clause
- Created: 2017-11-04T08:18:42.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-23T18:10:11.000Z (about 6 years ago)
- Last Synced: 2024-10-01T14:25:20.587Z (4 months ago)
- Topics: behavior, skeeks, slug, sluggable, slugify, yii, yii2, yii2-behavior, yii2-extension
- Language: PHP
- Homepage: https://skeeks.com
- Size: 25.4 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Yii2 slug behavior (Semantic URL)
===================================This solution allows you to generate good slug urls. ([slug wiki](https://en.wikipedia.org/wiki/Semantic_URL)).
Direct generation is engaged in a proven solution [cocur/slugify](https://github.com/cocur/slugify).
[![Latest Stable Version](https://img.shields.io/packagist/v/skeeks/yii2-slug-behavior.svg)](https://packagist.org/packages/skeeks/yii2-slug-behavior)
[![Total Downloads](https://img.shields.io/packagist/dt/skeeks/yii2-slug-behavior.svg)](https://packagist.org/packages/skeeks/yii2-slug-behavior)Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist skeeks/yii2-slug-behavior "*"
```or add
```
"skeeks/yii2-slug-behavior": "*"
```How to use
----------Attach the behavior in your model:
```php
public function behaviors()
{
return [
'slug' => [
'class' => 'skeeks\yii2\slug\SlugBehavior',
'slugAttribute' => 'slug', //The attribute to be generated
'attribute' => 'name', //The attribute from which will be generated
// optional params
'maxLength' => 64, //Maximum length of attribute slug
'minLength' => 3, //Min length of attribute slug
'ensureUnique' => true,
'slugifyOptions' => [
'lowercase' => true,
'separator' => '-',
'trim' => true
//'regexp' => '/([^A-Za-z0-9]|-)+/',
//'rulesets' => ['russian'],
//@see all options https://github.com/cocur/slugify
]
]
];
}```
Yandex translit http://translit-online.ru/yandex.html:
```php
public function behaviors()
{
return [
'slug' => [
'class' => 'skeeks\yii2\slug\SlugBehavior',
'slugAttribute' => 'slug', //The attribute to be generated
'attribute' => 'name', //The attribute from which will be generated
// optional params
'slugifyOptions' => [
'rulesets' => [
skeeks\yii2\slug\SlugRuleProvider::YANDEX,
'default'
]
]
]
];
}```
Links
----------
* [Github](https://github.com/skeeks-semenov/yii2-slug-behavior)
* [Changelog](https://github.com/skeeks-semenov/yii2-slug-behavior/blob/master/CHANGELOG.md)
* [Issues](https://github.com/skeeks-semenov/yii2-slug-behavior/issues)
* [Packagist](https://packagist.org/packages/skeeks/yii2-slug-behavior)Demo (view urls)
----------
* [https://skeeks.com](https://skeeks.com)___
> [![skeeks!](https://skeeks.com/img/logo/logo-no-title-80px.png)](https://skeeks.com)
SkeekS CMS (Yii2) — fast, simple, effective!
[skeeks.com](https://skeeks.com) | [cms.skeeks.com](https://cms.skeeks.com)