PHPackages                             dxw/php-missing - 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. dxw/php-missing

ActiveLibrary

dxw/php-missing
===============

The stdlib you wish PHP had

v2.0.0(2y ago)529.7k↓41.7%2[2 issues](https://github.com/dxw/php-missing/issues)[1 PRs](https://github.com/dxw/php-missing/pulls)MITPHPPHP ^7.4||^8.1

Since Nov 3Pushed 2y ago11 watchersCompare

[ Source](https://github.com/dxw/php-missing)[ Packagist](https://packagist.org/packages/dxw/php-missing)[ Docs](https://github.com/dxw/php-missing)[ RSS](/packages/dxw-php-missing/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (13)Used By (0)

php-missing
===========

[](#php-missing)

PHP's standard library contains a lot of stuff, but it's missing a lot of stuff. All these functions are basic things that I've had to implement over and over again.

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

[](#installation)

Install [composer](http://getcomposer.org/).

Run the following in the root of your project:

```
composer require dxw/php-missing

```

Or, create a composer.json file with the following contents and run "composer install":

```
{
  "require": {
    "dxw/php-missing": "^2.0"
  }
}

```

API
---

[](#api)

- [\\Missing\\Arrays::flatten](#arr_flatten)
- [\\Missing\\Arrays::sortBy](#arr_sort_by)
- [\\Missing\\Dates::parse](#date_parse)
- [\\Missing\\Dates::strftime](#date_strftime)
- [\\Missing\\Ints::ordinalize](#int_ordinalize)
- [\\Missing\\Reflection::call](#reflection_call)
- [\\Missing\\Strings::startsWith](#string_starts_with)
- [\\Missing\\Strings::endsWith](#string_ends_with)
- [\\Missing\\Strings::getOutput](#string_get_output)

### Arrays

[](#arrays)

#### $array = \\Missing\\Arrays::flatten($array)

[](#array--missingarraysflattenarray)

Flattens an array containing arrays.

```
\Missing\Arrays::flatten([1, [2, 3, [4, 5]]]) === [1, 2, 3, 4, 5]

```

#### $array = \\Missing\\Arrays::sortBy($array, $callback)

[](#array--missingarrayssortbyarray-callback)

Sorts $array by $callback($array\_element).

```
\Missing\Arrays::sortBy(['abc', 'ab', 'a'], function ($a) {return strlen($a);}) === ['a', 'ab', 'abc']

```

### Dates

[](#dates)

#### list($timestamp, $err) = \\Missing\\Dates::parse($str)

[](#listtimestamp-err--missingdatesparsestr)

Parses several common/standard time formats, returns a `Dxw\Result\Result` object containing either the UNIX timestamp or an error.

```
$result = \Missing\Dates::parse(get_post_meta($post->ID, '_EventStartDate', true));
if ($result->isErr()) {
  $date = 'Unknown date';
} else {
  $date = strftime('%e %B %Y', $result->unwrap());
}

```

The following date formats are parsed:

- %Y-%m-%dT%H:%M:%S
- %Y-%m-%d %H:%M:%S
- %Y-%m-%dT%H:%M
- %Y-%m-%d %H:%M
- %Y-%m-%d

#### $date = \\Missing\\Dates::strftime($date\_string, $format, $else, $tz)

[](#date--missingdatesstrftimedate_string-format-else-tz)

Parses $date\_string using \\Missing\\Dates::parse() (also accepts a UTC timestamp), if it parses correctly, return the date formatted with $format in the timezone $tz, otherwise return $else.

```
Date:

```

### Ints

[](#ints)

#### $string = \\Missing\\Ints::ordinalize($number)

[](#string--missingintsordinalizenumber)

Returns English ordinals for any given integer (i.e. 1 =&gt; "1st", 2 =&gt; "2nd").

Copied directly from active\_record's [Inflector#ordinalize](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-ordinalize) (also MIT licensed).

### Reflection

[](#reflection)

#### $value = \\Missing\\Reflection::call($object, $methodName, $arguments)

[](#value--missingreflectioncallobject-methodname-arguments)

Calls private or protected method $methodName of $object with $arguments (an array) and returns what it returns.

### Strings

[](#strings)

#### $bool = \\Missing\\Strings::startsWith($haystack, $needle)

[](#bool--missingstringsstartswithhaystack-needle)

Returns true if string $haystack starts with $needle (uses substr() - regexes not supported).

#### $bool = \\Missing\\Strings::endsWith($haystack, $needle)

[](#bool--missingstringsendswithhaystack-needle)

Returns true if string $haystack ends with $needle (uses substr() - regexes not supported).

#### $string = \\Missing\\Strings::getOutput($callback)

[](#string--missingstringsgetoutputcallback)

Executes $callback, returns what it prints as a string.

Licence
-------

[](#licence)

MIT - see COPYING.md

\\Missing\\Ints::ordinal and \\Missing\\Ints::ordinalize were ported from the Rails active\_support module, also licensed under MIT.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance12

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% 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 ~2618 days

Total

2

Last Release

1034d ago

Major Versions

v1.0.0 → v2.0.02023-07-19

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/370665?v=4)[Rob Skilling](/maintainers/RobjS)[@RobjS](https://github.com/RobjS)

![](https://avatars.githubusercontent.com/u/1659723?v=4)[jkeasley](/maintainers/jkeasley)[@jkeasley](https://github.com/jkeasley)

![](https://avatars.githubusercontent.com/u/4721596?v=4)[Matthew Passmore](/maintainers/matpassmore)[@matpassmore](https://github.com/matpassmore)

![](https://avatars.githubusercontent.com/u/71827088?v=4)[Serena Piccioni](/maintainers/serena-piccioni)[@serena-piccioni](https://github.com/serena-piccioni)

---

Top Contributors

[![mallorydxw](https://avatars.githubusercontent.com/u/2256130?v=4)](https://github.com/mallorydxw "mallorydxw (65 commits)")[![RobjS](https://avatars.githubusercontent.com/u/370665?v=4)](https://github.com/RobjS "RobjS (18 commits)")[![snim2](https://avatars.githubusercontent.com/u/97674?v=4)](https://github.com/snim2 "snim2 (4 commits)")[![holizz](https://avatars.githubusercontent.com/u/9224?v=4)](https://github.com/holizz "holizz (2 commits)")[![patdel0](https://avatars.githubusercontent.com/u/53922624?v=4)](https://github.com/patdel0 "patdel0 (2 commits)")

---

Tags

composergovpresspackagistphp

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dxw-php-missing/health.svg)

```
[![Health](https://phpackages.com/badges/dxw-php-missing/health.svg)](https://phpackages.com/packages/dxw-php-missing)
```

PHPackages © 2026

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