mouf/utils.common.sortable-interface
A small PHP package from Mouf that defines a common SortableInterface, helping standardize sortable behavior across libraries and components so objects can be sorted consistently in your codebase.
Architecture fit. This package is a single-interface artifact from the Mouf framework ecosystem (thecodingmachine), not Laravel. Its entire contract is "an object implements sort($key, $direction)." In a Laravel codebase, sorting is expressed idiomatically through Eloquent (orderBy, query scopes, reorder) or Collections (sortBy, sortByDesc, non-mutating return-a-new-instance semantics). The package's contract does not align with either: it implies an in-place mutation, exposes no return type, and takes an untyped $key (a column name) and $direction — precisely the two values Laravel developers normally route through a server-side allowlist before touching the query builder. Adopting it would push a foreign, Mouf-flavored abstraction into the domain layer for zero functional gain.
Integration feasibility. Mechanically trivial: MIT-licensed, Composer-installable, PSR-4 autoloadable, no runtime dependencies, no service provider, no config, no migrations. The real feasibility question is not "can we install it" but "should this class name appear in our dependency graph." At 1 star, 0 dependents, and a last release of 2017-05-17, the package has effectively no ecosystem validation — the composite score of 0.005 and opportunity signal of 45.45 should be read as discovery noise, not as latent value.
Technical risk.
mouf/installer or similar Composer plugins to register themselves with the Mouf container. Under Composer 2.2+ these are blocked by allow-plugins, which surfaces as interactive prompts or hard failures in CI. This must be verified in composer.json before any composer require.declare(strict_types=1). Consumers cannot know whether sort() returns void, $this, or a sorted copy — a real source of inconsistency across a multi-team codebase.sort(string $key, ...) invites callers to pass user input as a column name. The interface cannot enforce an allowlist; every implementer must remember to. That is a latent SQL-error/injection foot-gun encoded as a feature.composer audit and SCA tooling will find nothing.Key questions.
composer.json require a Composer plugin (mouf/installer or equivalent)? If yes, this is a non-starter for our CI.$direction — 'ASC'|'DESC', 'asc'|'desc', or booleans? Is it case-sensitive?sort() return, and is mutation or copy semantics intended?Stack fit. Poor. PHP-7-era, untyped signatures against a Laravel 10/11 runtime (PHP 8.1+) means the package installs fine but reads as legacy. It also conflicts conceptually with Collection sortBy semantics and with Eloquent's builder, so we would end up maintaining adapters to bridge a contract we don't need.
Migration path. There is nothing to migrate — no data, no schema, no state. The correct path is build, don't buy: define a local contract in app/Support/Contracts/Sortable.php (roughly twelve lines) with modern typing, e.g. public function sort(string $key, string $direction): static;, plus a SortDirection enum and a SortableWhitelist trait that validates $key against $sortable before it reaches orderBy. Cost: under a day. That also gives us reviewability and a place to hang the allowlist enforcement.
Compatibility. Only meaningful if we accept the Mouf lineage: verify Composer 2.x plugin allowances, confirm no container coupling, confirm autoload works standalone. If any of those checks fail, the package is unusable regardless of merit.
Sequencing.
Sortable contract + enum + whitelist trait in the shared support library.orderBy.Maintenance. Upstream is dormant — no releases since May 2017, no responsive maintainer. Paradoxically, a frozen interface is close to zero-maintenance: it cannot break, because it does nothing. The cost is entirely in cognitive and governance overhead — every new engineer who sees Mouf\...\SortableInterface in composer.json must investigate an unfamiliar framework to conclude it is inert. That is a permanent, small tax for a temporary convenience.
Support. None. One star, zero dependents, no issue activity. Internal on-call will be the effective maintainer of any behavior we build on it — which argues for owning the twelve lines ourselves.
Scaling. No runtime cost: no code executes, no I/O, no memory. It will not affect request latency, queue throughput, or horizontal scaling at any volume. The scaling concern is organizational: an unmaintained dependency in a platform shared by many teams multiplies the "is this safe?" question across every consuming team.
Failure modes.
allow-plugins is negotiated.$request->input('sort') directly as $key; the implementation interpolates it into a query and produces a SQL error or, depending on the driver, worse.'desc', another 'DESC', a third true. Manifests as silently wrong ordering, which is the worst class of bug: it looks like data, not like code.thecodingmachine dependency in a Laravel stack and asks why. There is no good answer.Ramp-up. Effectively instantaneous for the interface itself — a competent PHP engineer understands sort($key, $direction) in seconds. The non-trivial ramp is on the surrounding conventions: whether the column name is trusted, what the direction vocabulary is, and whether the operation mutates. Those gaps are exactly what the package does not solve, and exactly what a local contract would.
Recommendation. Do not adopt. The package is a 2017 single-interface artifact from a framework we don't use, with no dependents and no maintenance, offering a contract we would have to constrain, wrap, and document before it was safe. Reimplement the pattern locally with strict types, a direction enum, and an enforced column allowlist; record the rejection and move on. Adoption is only defensible if a hard requirement exists to interoperate with a third-party Mouf-based library — and even then, a local adapter implementing our own interface, with the dependency confined to that adapter, is the better boundary.
How can I help you explore Laravel packages today?