Automatic creation of friendly links based on indicated field.
It's developed for CakePHP 4.x.
You can install plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require slicesofcake/slug
Load the behavior in /src/Model/Table/YourTable.php
.
public function initialize(array $config): void
{
// ...
$this->addBehavior('SlicesCake/Slug.Slug');
}
You can configuration to customize the Slug plugin:
$this->addBehavior('SlicesCake/Slug.Slug', [
'slug' => [ // Target field name of column to store slugs, default is slug
'source' => 'name', // Source field name to create slug, default is title
'replacement' => '_', // Default is -
'finder' => 'some', // You can build own custom finder method, like findSome, default is built-in list
'present' => true, // Rewrite slug, default is false, was added in 1.1.0
'method' => 'someOther', // You can build own method for create string slug, now default is built-in Text::slug, was added in 1.2.0
],
]);