PHPackages                             sherlockode/sonata-sortable-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. sherlockode/sonata-sortable-bundle

ActiveSymfony-bundle

sherlockode/sonata-sortable-bundle
==================================

Symfony Bundle for managing entities positions with Sonata admin

v0.1.0(3y ago)024MITPHPPHP ^8.1

Since Dec 7Pushed 3y ago5 watchersCompare

[ Source](https://github.com/sherlockode/SonataSortableBundle)[ Packagist](https://packagist.org/packages/sherlockode/sonata-sortable-bundle)[ RSS](/packages/sherlockode-sonata-sortable-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

Installation
============

[](#installation)

Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

Applications that use Symfony Flex
----------------------------------

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

```
$ composer require sherlockode/sonata-sortable-bundle
```

Applications that don't use Symfony Flex
----------------------------------------

[](#applications-that-dont-use-symfony-flex)

### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require sherlockode/sonata-sortable-bundle
```

### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    Sherlockode\SonataSortableBundle\SherlockodeSonataSortableBundle::class => ['all' => true],
];
```

Sortable behavior in admin listing
==================================

[](#sortable-behavior-in-admin-listing)

Pre-requisites
--------------

[](#pre-requisites)

You need to have a working Sonata admin and to have installed and configured `gedmo/doctrine-extensions` (check `stof/doctrine-extensions-bundle` for easy integration).

The recipe
----------

[](#the-recipe)

First of all, add a position property in your entity

```
// src/Entity/Category.php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

/**
 * @ORM\Table(name="category")
 * @ORM\Entity
 */
class Category
{
    /**
     * @var int
     *
     * @Gedmo\SortablePosition
     * @ORM\Column(name="position", type="integer")
     */
    private $position;
}
```

To change this position with Sonata, we need to add a new route in our admin:

```
// src/Admin/CategoryAdmin.php

namespace App\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Route\RouteCollectionInterface;

class CategoryAdmin extends AbstractAdmin
{
    // ...

    /**
     * @param RouteCollectionInterface $collection
     *
     * @return void
     */
    protected function configureRoutes(RouteCollectionInterface $collection): void
    {
        $collection->add('move', $this->getRouterIdParameter().'/move/{direction}');
    }
}
```

Update the admin configuration to use our custom controller

```
services:
    admin.category:
        class: 'App\Admin\CategoryAdmin'
        arguments: [ ~, App\Entity\Category, 'Sherlockode\SonataSortableBundle\Controller\SortableController' ]
        tags:
            - { name: sonata.admin, manager_type: orm, label: Categories }
```

Then, add default sort by position in the admin:

```
// src/Admin/CategoryAdmin.php

namespace App\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridInterface;

class CategoryAdmin extends AbstractAdmin
{
    // ...

    protected function configureDefaultSortValues(array &$sortValues): void
    {
        $sortValues[DatagridInterface::PAGE] = 1;
        $sortValues[DatagridInterface::SORT_ORDER] = 'ASC';
        $sortValues[DatagridInterface::SORT_BY] = 'position';
    }
}
```

Add controls to allow the user to change the position of items:

```
// src/Admin/CategoryAdmin.php

namespace App\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper;

class CategoryAdmin extends AbstractAdmin
{
    // ...

    /**
     * @inheritDoc
     */
    protected function configureListFields(ListMapper $list): void
    {
        $list
            // your other fields
            ->add(ListMapper::NAME_ACTIONS, null, [
                'actions' => [
                    'move' => [
                        'template' => '@SherlockodeSonataSortable/list__action_move.html.twig',
                    ],
                ],
            ])
        ;
    }
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1258d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fafd942dc78112d2a4b4088c8a07d01557590ee22e5881587afe6b16ad92c6d1?d=identicon)[sherlockode](/maintainers/sherlockode)

---

Top Contributors

[![NeilPeyssard](https://avatars.githubusercontent.com/u/12657400?v=4)](https://github.com/NeilPeyssard "NeilPeyssard (2 commits)")[![Vowow](https://avatars.githubusercontent.com/u/3932842?v=4)](https://github.com/Vowow "Vowow (1 commits)")

### Embed Badge

![Health badge](/badges/sherlockode-sonata-sortable-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/sherlockode-sonata-sortable-bundle/health.svg)](https://phpackages.com/packages/sherlockode-sonata-sortable-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[stof/doctrine-extensions-bundle

Integration of the gedmo/doctrine-extensions with Symfony

1.9k85.3M381](/packages/stof-doctrine-extensions-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[networking/init-cms-bundle

This Bundle is a basic cms based on symfony

1006.0k2](/packages/networking-init-cms-bundle)[pumukit/pumukit

Media Portal

5714.0k37](/packages/pumukit-pumukit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
