Skip to main content

Posts

Showing posts from January, 2019

Learn Nested Set on Yii2 Framework

The nested set behaviour is an approach to store hierarchical data in relational databases. For example, if we have many categories for our product or items. One category can be a "parent" for other categories, means that one category consists of more than one category. The model can be drawn using a "tree" model. There are other approaches available but what we will learn in this article is specifically the NestedSetsBehavior made by  Alexander Kochetov, which utilizing the Modified Preorder Tree Traversal algorithm.

Install Yii2 framework advanced template
My assumption is that we have our standard installation of Yii2 framework advanced template. You can read more about advanced template from the repository page on Github: https://github.com/yiisoft/yii2-app-advanced. Make sure that our installation is working by calling the default URL localhost:8080 after running the following command

$ ./yii serve --docroot="backend/web"

We also need to make sure tha…