Download the PHP package serj/sortable-tree without Composer

On this page you can find all versions of the php package serj/sortable-tree. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sortable-tree

yii2-sortable-tree

A set of classes for Yii2 to create and maintain a tree-like structure.

Installation

To import the component to your project, put the following line to the require section of your composer.json file:

or run the command

To create database tables apply a migration.

Usage

Adding a root

Adding a nested item

Assume that root item has an id = 1. To add an item under the root:

Let's add another item, but insert it before previous one. We assume that last inserted item has id = 2.

For the moment, our tree looks like this:

Moving items

Let's swap items 2 and 3

Now it should be like this:

Let's nest the item 3 into the item 2

The result is:

Deletion

We deleted item 2 and its child 3. The root item left.

Getting the tree

There are many other methods to work with the tree. For more information you can explore public methods of the Tree class and unit tests.

I want to store more data

Lets suppose you want to store title, created_at, updated_at fields. And you no longer want to remove items from the tree, but mark them as deleted. To achieve this, we can extend the Tree calss. But first, let's modify a migration.

Do not forget to apply a new migration.

Extend the tree class. Add and overwrite some methods.

To skip deleted items we've added a filter in the class constructor. Let's implement it.

Now to add an item, pass an array of extra attributes that was added to migration. In or case it's title.

To edit a title of the existing item:

For deletion use the same method as above.

Tree class triggers a set of events, which might be useful.

For example to get ids of the items before they are deleted:

Using with MySql database (by default it's Postgres)


All versions of sortable-tree with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
yiisoft/yii2 Version ~2.0.6
serj/sortable Version ~1.2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package serj/sortable-tree contains the following files

Loading the files please wait ....