Download the PHP package chamber-orchestra/doctrine-sort-bundle without Composer

On this page you can find all versions of the php package chamber-orchestra/doctrine-sort-bundle. 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 doctrine-sort-bundle

PHP Composer codecov PHPStan Latest Stable Version License PHP 8.5 Doctrine ORM 3 Symfony 8

Doctrine Sort Bundle

Symfony bundle for automatic sort order management in Doctrine ORM entities. Recalculates sort positions on every EntityManager::flush(), keeping ordered lists consistent without manual reindexing. Uses PHP attributes to mark the sort field, supports grouped ordering (e.g., per parent or category), and handles insertions, deletions, and reordering transparently.

Features

Installation

If Symfony Flex is enabled, the bundle is registered automatically. Otherwise, add it to config/bundles.php:

Quick Start

1. Mark a sort field

Add the #[Sort] attribute to any integer column. The bundle will automatically maintain sequential ordering starting from 1.

2. Grouped ordering

Maintain separate sort sequences per parent, category, or any relation:

3. Using traits

For common cases, use the provided traits instead of writing boilerplate:

SortTrait provides getSortOrder(), setSortOrder(), and convenience methods:

Method Effect
moveUp() Decrease sort position by 1 (minimum 1)
moveDown() Increase sort position by 1
moveToBeginning() Set sort position to 1
moveToEnd() Set sort position to 0 (appends to end)

SortByParentTrait extends SortTrait with a $parent ManyToOne field and #[Sort(groupBy: ['parent'])].

Attribute Options

Option Type Default Description
groupBy array [] Entity field names that define sort groups. Each unique combination of group values has its own sort sequence. Supports Column, ManyToOne, and ManyToMany fields.
evictCollections array [] List of [FQCN, collectionField] pairs. These Doctrine second-level cache collections are evicted when sort order changes.
evictRegions array [] Query cache region names to evict when sort order changes.

How It Works

  1. The bundle listens to Doctrine's onFlush event
  2. For each entity with a #[Sort] attribute that was inserted, updated, or deleted, it collects the changes
  3. Overlapping changes within the same group are merged into ranges to minimize database queries
  4. Affected entities are fetched, reordered in memory, and sort values are reassigned sequentially
  5. Doctrine's recomputeSingleEntityChangeSet() ensures the corrected values are persisted in the same flush

This means you never need to manually manage gaps, shift items, or renumber sequences — just set the desired position and flush. Multiple reorder operations within a single flush or across multiple flushes in an explicit transaction are fully supported.

Compatibility

Bundle PHP Symfony Doctrine ORM
8.0 ^8.5 8.0 3.6+

Running Tests

License

MIT


All versions of doctrine-sort-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ext-ds Version ^2.0
chamber-orchestra/metadata-bundle Version 8.1.*
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 chamber-orchestra/doctrine-sort-bundle contains the following files

Loading the files please wait ...