Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

NetTuts.com:
Programming With Yii2: Sluggable Behavior
May 13, 2015 @ 17:53:33

NetTuts.com has continued their series looking at programming with the Yii2 framework in this latest part of the series covering the "sluggable" behavior the framework includes.

In this Programming With Yii2 series, I'm guiding readers in use of the newly upgraded Yii2 Framework for PHP. In this tutorial, I'm going to show you how to modify 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. For these examples, we'll continue to imagine we're building a framework for posting simple status updates, e.g. our own mini-Twitter.

They start the tutorial off by defining what a "slug" is for those that may not have used them before. From there they show you how to add in the behavior to the current version of their sample application, adding a new "slug" column to their status table. They then update the status model to reflect the changes and test it out with the insert of a new update. They also show how to implement the slug handling in your routing and add the functionality to the controller to handle the different request. They finish off the post with a mention of managing permanence and uniqueness to prevent overlaps.

tagged: series yii2 framework sluggable slug functionality tutorial

Link: http://code.tutsplus.com/tutorials/programming-with-yii2-sluggable-behavior--cms-23222


Trending Topics: