PHPackages                             admad/cakephp-sequence - 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. [Database &amp; ORM](/categories/database)
4. /
5. admad/cakephp-sequence

ActiveCakephp-plugin[Database &amp; ORM](/categories/database)

admad/cakephp-sequence
======================

Sequence plugin for CakePHP to maintain ordered list of records

4.0.1(9mo ago)45531.0k↓44.8%156MITPHPCI passing

Since Dec 1Pushed 8mo ago3 watchersCompare

[ Source](https://github.com/ADmad/cakephp-sequence)[ Packagist](https://packagist.org/packages/admad/cakephp-sequence)[ GitHub Sponsors](https://github.com/ADmad)[ RSS](/packages/admad-cakephp-sequence/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (3)Versions (22)Used By (6)

Sequence plugin to maintain ordered list of records
===================================================

[](#sequence-plugin-to-maintain-ordered-list-of-records)

[![Build Status](https://camo.githubusercontent.com/b47c139ea73d6ea0c483b04bed4f8a9876b79b62530eb46ab18bae02ea8b93f1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f41446d61642f63616b657068702d73657175656e63652f63692e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/ADmad/cakephp-sequence/actions/workflows/ci.yml)[![Coverage](https://camo.githubusercontent.com/ce6ad66b5ae40032b96399687a2f70c20b65d5310b2d2a42b12e4a854134c8fc/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f41446d61642f63616b657068702d73657175656e63652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/ADmad/cakephp-sequence)[![Total Downloads](https://camo.githubusercontent.com/bf0bc9b3754fa5d312886782a869ba1b24032eba8ed29aeec48d534d49b3f1c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61646d61642f63616b657068702d73657175656e63652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/admad/cakephp-sequence)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)

Installation
------------

[](#installation)

Install this plugin into your CakePHP application using [composer](http://getcomposer.org):

```
composer require admad/cakephp-sequence

```

Then load the plugin by running CLI command:

```
./bin/cake plugin load ADmad/Sequence
```

How it works
------------

[](#how-it-works)

`SequenceBehavior` provided by this plugin maintains a contiguous sequence of integers in a selected column, for records in a table (optionally with grouping) when adding, editing (including moving groups) or deleting records.

Usage
-----

[](#usage)

Add the `SequenceBehavior` for your table and viola:

```
$this->addBehavior('ADmad/Sequence.Sequence');
```

You can customize various options as shown:

```
$this->addBehavior('ADmad/Sequence.Sequence', [
    'sequenceField' => 'position', // Field to use to store integer sequence. Default "position".
    'scope' => ['group_id'], // Array of field names to use for grouping records. Default [].
    'startAt' => 1, // Initial value for sequence. Default 1.
]);
```

Now whenever a new record is added its `position` field will be automatically set to current largest value in sequence plus one.

When editing records you can set the position to a new value and the position of other records in the list will be automatically updated to maintain proper sequence.

When doing a find on the table an order clause is automatically added to the query to order by the position field if an order clause has not already been set.

### Methods

[](#methods)

#### moveUp(\\Cake\\Datasource\\EntityInterface $entity)

[](#moveupcakedatasourceentityinterface-entity)

Move up record by one position:

```
$modelObject->moveUp($entity);
```

#### moveDown(\\Cake\\Datasource\\EntityInterface $entity)

[](#movedowncakedatasourceentityinterface-entity)

Move down record by one position:

```
$modelObject->moveDown($entity);
```

#### setOrder(array $record)

[](#setorderarray-record)

Set order for list of records provided. Records can be provided as array of entities or array of associative arrays like `[['id' => 1], ['id' => 2]]` or array of primary key values like `[1, 2]`.

Acknowledgement
---------------

[](#acknowledgement)

Shout out to @neilcrookes for his wonderful Sequence Behavior for CakePHP 1.3 which was the inspiration for this plugin.

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance58

Moderate activity, may be stable

Popularity50

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 83.2% 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 ~181 days

Recently: every ~401 days

Total

21

Last Release

281d ago

Major Versions

1.0.1 → 2.0.02016-02-05

2.3.1 → 3.0.0-beta2019-12-17

2.x-dev → 3.0.02020-07-07

3.x-dev → 4.0.02023-09-29

### Community

Maintainers

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

---

Top Contributors

[![ADmad](https://avatars.githubusercontent.com/u/142658?v=4)](https://github.com/ADmad "ADmad (109 commits)")[![dakota](https://avatars.githubusercontent.com/u/83255?v=4)](https://github.com/dakota "dakota (6 commits)")[![josegonzalez](https://avatars.githubusercontent.com/u/65675?v=4)](https://github.com/josegonzalez "josegonzalez (5 commits)")[![veganista](https://avatars.githubusercontent.com/u/405763?v=4)](https://github.com/veganista "veganista (2 commits)")[![bravo-kernel](https://avatars.githubusercontent.com/u/230500?v=4)](https://github.com/bravo-kernel "bravo-kernel (2 commits)")[![lorenzo](https://avatars.githubusercontent.com/u/37621?v=4)](https://github.com/lorenzo "lorenzo (2 commits)")[![adayth](https://avatars.githubusercontent.com/u/1223929?v=4)](https://github.com/adayth "adayth (2 commits)")[![LordSimal](https://avatars.githubusercontent.com/u/9105243?v=4)](https://github.com/LordSimal "LordSimal (1 commits)")[![curtisgibby](https://avatars.githubusercontent.com/u/1086964?v=4)](https://github.com/curtisgibby "curtisgibby (1 commits)")[![AReveron](https://avatars.githubusercontent.com/u/41989865?v=4)](https://github.com/AReveron "AReveron (1 commits)")

---

Tags

cakephpcakephp-pluginphpsequencesortingormcakephplistsequence

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/admad-cakephp-sequence/health.svg)

```
[![Health](https://phpackages.com/badges/admad-cakephp-sequence/health.svg)](https://phpackages.com/packages/admad-cakephp-sequence)
```

###  Alternatives

[josegonzalez/cakephp-upload

CakePHP plugin to handle file uploading sans ridiculous automagic

5551.5M12](/packages/josegonzalez-cakephp-upload)[muffin/trash

Adds soft delete support to CakePHP ORM tables.

881.5M11](/packages/muffin-trash)[cakephp/migrations

Database Migration plugin for CakePHP

13413.2M316](/packages/cakephp-migrations)[muffin/webservice

Simplistic webservices for CakePHP

88197.8k14](/packages/muffin-webservice)[riesenia/cakephp-duplicatable

CakePHP ORM plugin for duplicating entities (including related entities)

51415.2k4](/packages/riesenia-cakephp-duplicatable)[muffin/slug

Slugging support for CakePHP ORM

37280.9k5](/packages/muffin-slug)

PHPackages © 2026

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