PHPackages                             muffin/orderly - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. muffin/orderly

ActiveCakephp-plugin[Utility &amp; Helpers](/categories/utility)

muffin/orderly
==============

Default ordering (behavior) for CakePHP

3.0.1(1y ago)22217.3k—0.5%51MITPHPCI passing

Since Feb 5Pushed 4mo ago5 watchersCompare

[ Source](https://github.com/UseMuffin/Orderly)[ Packagist](https://packagist.org/packages/muffin/orderly)[ Docs](https://github.com/usemuffin/orderly)[ RSS](/packages/muffin-orderly/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (11)Used By (1)

Orderly
=======

[](#orderly)

[![Build Status](https://camo.githubusercontent.com/5708bde77f4113e9de98fab391b79c30944d013b8d0e6e1a37d40a86734fd769/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f5573654d756666696e2f4f726465726c792f63692e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/UseMuffin/Orderly/actions/workflows/ci.yml?query=branch%3Amaster)[![Coverage](https://camo.githubusercontent.com/b83e6313f9344ccd655d027a5974eb9f930a3ff5cafb9a1414556dd8f04b5717/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f5573654d756666696e2f4f726465726c792f6d61737465723f7374796c653d666c61742d737175617265)](https://app.codecov.io/gh/UseMuffin/Orderly)[![Total Downloads](https://camo.githubusercontent.com/b52df07ab14dd36fd0c6ae2e358a3cf99ba09baf02bf8c915279492ae47d1295/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d756666696e2f6f726465726c792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muffin/orderly)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Allows setting default order for your tables.

Install
-------

[](#install)

Using [Composer](http://getcomposer.org):

```
composer require muffin/orderly
```

Then load the plugin using the console command:

```
bin/cake plugin load Muffin/Orderly
```

What is does
------------

[](#what-is-does)

Orderly allow you to set default `ORDER` clause for your table's `SELECT` queries.

Usage
-----

[](#usage)

Here's how you can add the `Orderly` behavior for your tables:

```
// By default orders by display field of table.
$this->addBehavior('Muffin/Orderly.Orderly');

// Default ordering using specified field.
$this->addBehavior('Muffin/Orderly.Orderly', ['order' => $this->aliasField('field_name')]);
```

Value for `order` key can any valid value that `\Cake\ORM\Query\SelectQuery::orderBy()` takes. The default order clause will only be applied to the primary query and when no custom order clause has already been set for the query.

You can also configure the behavior to apply the default order based on required condition using `callback` option. The order will be applied if callback returns `true`:

```
$this->addBehavior('Muffin/Orderly.Orderly', [
    'order' => ['Alias.field_name' => 'DESC'],
    'callback' => function (SelectQuery $query, ArrayObject $options, bool $primary) {
        //return a boolean
    }
]);
```

The behavior can also be configured with multiple orders which are applied based on return value of their respective callbacks:

```
$this->addBehavior('Muffin/Orderly.Orderly', [
    [
        'order' => ['Alias.field_name' => 'DESC'],
        'callback' => function (SelectQuery $query, ArrayObject $options, bool $primary) {
            //return a boolean
        }
    ],
    [
        'order' => ['Alias.another_field'],
        'callback' => function (SelectQuery $query, ArrayObject $options, bool $primary) {
            //return a boolean
        }
    ],
]);
```

Patches &amp; Features
----------------------

[](#patches--features)

- Fork
- Mod, fix
- Test - this is important, so it's not unintentionally broken
- Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of their own that I can ignore when I pull)
- Pull request - bonus point for topic branches

To ensure your PRs are considered for upstream, you MUST follow the [CakePHP coding standards](http://book.cakephp.org/5/en/contributing/cakephp-coding-conventions.html).

Bugs &amp; Feedback
-------------------

[](#bugs--feedback)

License
-------

[](#license)

Copyright (c) 2015-Present, [Use Muffin](http://usemuffin.com) and licensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php).

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance59

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 97.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 ~354 days

Recently: every ~413 days

Total

10

Last Release

567d ago

Major Versions

1.1.0 → 2.0.0-beta2019-12-17

1.x-dev → 2.0.0-RC2020-04-21

2.x-dev → 3.0.02023-09-27

### 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 (43 commits)")[![jadb](https://avatars.githubusercontent.com/u/33527?v=4)](https://github.com/jadb "jadb (1 commits)")

---

Tags

cakephpcakephp-pluginorderingphpcakephpmuffinorderly

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/muffin-orderly/health.svg)

```
[![Health](https://phpackages.com/badges/muffin-orderly/health.svg)](https://phpackages.com/packages/muffin-orderly)
```

###  Alternatives

[markstory/asset_compress

An asset compression plugin for CakePHP. Provides file concatenation and a flexible filter system for preprocessing and minification.

3761.0M11](/packages/markstory-asset-compress)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

338920.1k32](/packages/dereuromark-cakephp-tools)[muffin/trash

Adds soft delete support to CakePHP ORM tables.

851.3M11](/packages/muffin-trash)[markstory/mini-asset

An asset compression library. Provides file concatenation and a flexible filter system for preprocessing and minification.

66741.1k3](/packages/markstory-mini-asset)[dereuromark/cakephp-shim

A CakePHP plugin to shim applications between major framework versions.

401.0M11](/packages/dereuromark-cakephp-shim)[muffin/webservice

Simplistic webservices for CakePHP

88191.0k13](/packages/muffin-webservice)

PHPackages © 2026

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