Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
/ slug Public archive

CakePHP plugin for friendly URLs with slugs

License

Notifications You must be signed in to change notification settings

slicesofcake/slug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CakePHP plugin for slugs

Build Status Scrutinizer Code Quality LICENSE Releases

Automatic creation of friendly links based on indicated field.

Requirements

It's developed for CakePHP 4.x.

Installation

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

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
    ],
]);