PHPackages                             sgh/comparable-filesystem - 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. sgh/comparable-filesystem

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sgh/comparable-filesystem
=========================

Provides Comparators for the file system.

v1.1.1(11y ago)012MITPHPPHP &gt;=5.4.0

Since Mar 31Pushed 11y ago1 watchersCompare

[ Source](https://github.com/schmengler/comparable-filesystem)[ Packagist](https://packagist.org/packages/sgh/comparable-filesystem)[ Docs](https://github.com/schmengler/comparable-filesystem)[ RSS](/packages/sgh-comparable-filesystem/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Comparable-Filesystem
=====================

[](#comparable-filesystem)

[![Author](https://camo.githubusercontent.com/2e77af773c3c248fbc46eea4a88a1f2328a3d05f48b5e902a58db98ae9055de4/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d40667363686d656e676c65722d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/fschmengler)[![Latest Version](https://camo.githubusercontent.com/1bde30d1bb85bd16eca731e3dc094a279d4356215605b531a67293a9c16df40f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7367682f636f6d70617261626c652d66696c6573797374656d2e737667)](https://packagist.org/packages/sgh/comparable-filesystem)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/c543bd8bb3b7edc9433e443dd99de34f8f8173c63024131843cbb584d8aeba49/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7363686d656e676c65722f636f6d70617261626c652d66696c6573797374656d2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/schmengler/comparable-fileystem)

This package provides Comparators for the file system, i.e. for SplFileInfo objects. They can be used with the sorting and comparing tools in the [Comparable](https://github.com/schmengler/Comparator-Tools) package.

Requirements
------------

[](#requirements)

The package requires PHP 5.4 or later and the Comparable package in version 1.0 or later.

Install
-------

[](#install)

Via Composer

```
$ composer require sgh/comparable-filesystem
```

Usage
-----

[](#usage)

The following comparators are available:

- FileATimeComparator
- FileCTimeComparator
- FileMTimeComparator
- FileNameComparator
- FileSizeComparator
- FileTypeComparator

You can use all the methods in `\SGH\Comparable\SortFunctions` and `\SGH\Comparable\SetFunctions` with the comparators. If you prefer, you can also use the factory method `::callback()` to retrieve a comparison callback, that can be used in any function that expects a user defined comparison callback:

```
usort($arrayOfFiles, \SGH\Comparable\Filesystem\Comparator\FileSizeComparator::callback());

```

Testing
-------

[](#testing)

```
$ phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- Fabian Schmengler()
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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 ~5 days

Total

2

Last Release

4060d ago

### Community

Maintainers

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

---

Tags

comparatorcomparablesplfileinfo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sgh-comparable-filesystem/health.svg)

```
[![Health](https://phpackages.com/badges/sgh-comparable-filesystem/health.svg)](https://phpackages.com/packages/sgh-comparable-filesystem)
```

###  Alternatives

[phootwork/lang

Missing PHP language constructs

1224.8M8](/packages/phootwork-lang)[sgh/comparable

Provides Comparable and Comparator interfaces and methods to sort and compare objects based on these.

1473.7k2](/packages/sgh-comparable)[dragon-code/benchmark

Simple comparison of code execution speed between different options

11934.7k5](/packages/dragon-code-benchmark)[myclabs/array-comparator

Array comparator

19182.5k](/packages/myclabs-array-comparator)[jelix/version

Parse any version syntax, including semantic version. Compare version, using Composer version constraints syntax.

13193.0k4](/packages/jelix-version)[nette/coding-standard

41930.0k15](/packages/nette-coding-standard)

PHPackages © 2026

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