1. Go to this page and download the library: Download skeeks/yii2-slug-behavior library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
skeeks / yii2-slug-behavior example snippets
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
]
]
];
}
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'
]
]
]
];
}
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.