Download the PHP package rutorika/sortable without Composer

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


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.

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

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads Latest Unstable Version License

Laravel 5 - Demo


Install package through Composer

Version Compatibility

Laravel Rutorika Sortable
4 1.2.x (branch laravel4)
<=5.3 3.2.x
5.4 3.4.x
5.5 4.2.x
5.7 4.7.x
6.0 6.0.x
7.x, 8.x 8.x.x
9.x, 10.x 9.x.x

Sortable Trait

Adds sortable behavior to Eloquent (Laravel) models


Add position field to your model (see below how to change this name):

Add \Rutorika\Sortable\SortableTrait to your Eloquent model.

if you want to use custom column name for position, set $sortableField:

Now you can move your entities with methods moveBefore($entity) and moveAfter($entity) (you dont need to save model after that, it has saved already):

Also this trait automatically defines entity position on the create event, so you do not need to add position manually, just create entities as usual:

This entity will be at position entitiesMaximumPosition + 1

To get ordered entities use the sorted scope:

Note : Resorting does not take place after a record is deleted. Gaps in positional values do not affect the ordering of your lists. However, if you prefer to prevent gaps you can reposition your models using the deleting event. Something like:

You need rutorika-sortable >=2.3 to use ->next()

Sortable groups

if you want group entity ordering by field, add to your model

now moving and ordering will be encapsulated by this field.

If you want group entity ordering by many fields, use as an array:

Sortable many to many

Let's assume your database structure is

and you want to order tags for each post

Add position column to the pivot table (you can use any name you want, but position is used by default)

Add \Rutorika\Sortable\BelongsToSortedManyTrait to your Post model and define belongsToSortedMany relation provided by this trait:

Note: $this->belongsToSortedMany has different signature then $this->belongsToMany -- the second argument for this method is $orderColumn ('position' by default), next arguments are the same

Attaching tags to post with save/sync/attach methods will set proper position

Getting related model is sorted by position

You can reorder tags for given post

Many to many demo: (code)

You can also use polymorphic many to many relation with sortable behavour by using the MorphsToSortedManyTrait trait and returning $this->morphToSortedMany() from relation method.

By following the Laravel polymorphic many to many table relation your tables should look like

And your model like

Sortable Controller

Also this package provides \Rutorika\Sortable\SortableController, which handle requests to sort entities


Add the service provider to config/app.php

publish the config:

Add models you need to sort in the config config/sortable.php:

Add route to the sort method of the controller:

Now if you post to this route valid data:

Then entity with \Input::get('id') id will be moved relative by entity with \Input::get('positionEntityId') id.

For example, if request data is:

then the article with id 3 will be moved after the article with id 14.

jQuery UI sortable example

Note: Laravel 5 has csrf middleware enabled by default, so you should setup ajax requests:


Template for many to many ordering


All versions of sortable with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.5
illuminate/support Version ^7.0|^8.0|^9.0|^10.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 rutorika/sortable contains the following files

Loading the files please wait ....