On the web, slug is a short text used in a URL to identify and describe a resource. A slug is the part of a URL which identifies a page using human-readable keywords. Sluggable behavior is the Yii2 model behavior that allows us to generate unique slugs.
In this section, we will be guiding you through modifying Yii's default view URL routes for model objects to be more user-friendly and search engine-friendly. Yii provides built-in support for this via its sluggable behaviors.
Create a new application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
Set up the database connection and create a table named
blog_post
, as follows:DROP TABLE IF EXISTS 'blog_post'; CREATE TABLE IF NOT EXISTS 'blog_post' ( 'id' INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, 'title' VARCHAR(255) NOT NULL, 'slug' VARCHAR(255) NOT NULL, 'text' TEXT NOT NULL, PRIMARY KEY...