PHP code example of slicesofcake / slug

1. Go to this page and download the library: Download slicesofcake/slug 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/ */

    

slicesofcake / slug example snippets


public function initialize(array $config): void
{
    // ...

    $this->addBehavior('SlicesCake/Slug.Slug');
}

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