PHPackages                             koded/stdlib - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. koded/stdlib

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

koded/stdlib
============

A standard library for shareable classes and functions

6.4.2(10mo ago)49.8k↓100%4BSD-3-ClausePHPPHP ^8.1CI passing

Since May 1Pushed 10mo ago2 watchersCompare

[ Source](https://github.com/kodedphp/stdlib)[ Packagist](https://packagist.org/packages/koded/stdlib)[ RSS](/packages/koded-stdlib/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (2)Versions (29)Used By (4)

Koded Standard Library
======================

[](#koded-standard-library)

A standard library for shareable classes and functions.

[![CI](https://github.com/kodedphp/stdlib/actions/workflows/ci.yml/badge.svg)](https://github.com/kodedphp/stdlib/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/0e16a675dfa90af5cd03709949520861a1ee201315afb79563d83ce4a0217d5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6f6465642f7374646c69622e737667)](https://packagist.org/packages/koded/stdlib)[![Packagist Downloads](https://camo.githubusercontent.com/48be518d85fb71ec2327342a09bf347ac5270df3fb127e63d986ba901b09d7ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6f6465642f7374646c69622e737667)](https://packagist.org/packages/koded/stdlib)[![Minimum PHP Version](https://camo.githubusercontent.com/183804d09fec16ca7b6209b007250b7d8db1b915042feb093a9f20e6e1f25359/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e312d3838393242462e737667)](https://php.net/)

Classes
-------

[](#classes)

### `Immutable`

[](#immutable)

- `get(string $index, $default = null)`
- `has($index): bool`
- `equals(string $propertyA, string $propertyB): bool`
- `find(string $index, $default = null)`
- `extract(array $keys): array`
- `filter(iterable $data, string $prefix, bool $lowercase = true, bool $trim = true): array`
- `namespace(string $prefix, bool $lowercase = true, bool $trim = true)`
- `count()`
- `toArray(): array`
- `toJSON(int $options = 0): string`
- `toXML(string $root): string`
- `toArguments(): Arguments`

### `Arguments`

[](#arguments)

(implements `Immutable` methods)

- `set(string $index, $value)`
- `import(array $values)`
- `upsert(string $index, $value)`
- `bind(string $index, &$variable)`
- `pull(string $index, $default = null)`
- `delete(string $index)`
- `clear()`
- `toImmutable(): Immutable`

### `ExtendedArguments`

[](#extendedarguments)

`ExtendedArguments extends Arguments`

- `flatten(): ExtendedArguments`

Supports *dot-notation* for index names. Example:

```
$args = new \Koded\Stdlib\ExtendedArguments([
    'foo' => [
        'bar' => [
            'baz' => 42
        ]
    ]
]);

$args->get('foo.bar');
// returns ['baz' => 42]

$args->get('foo.bar.baz');
// returns 42

$args->flatten();
// returns ['foo.bar.baz' => 42]

$args->set('foo.bar', 'baz');
// ['foo' => ['bar' => 'baz']]
```

### `Config`

[](#config)

Class `Config` works as a parameter bag that provides ways to fill it from files or other `Config` instances. There are 2 common patterns to populate the config,

either you can fill the Config instance from config files:

```
$app->config()->fromPhpFile('myconfig.php');
$app->config()->fromJsonFile('myconfig.json');
$app->config()->fromEnvFile('.env');
$app->config()->fromIniFile('myconfig.ini');
```

or alternatively you can define the configuration options in the instance that calls `fromObject`,

```
$app->config()->fromObject(MyConfig::class);
$app->config()->fromObject($myconfig); // $myconfig is instance of Config
```

Other interesting way to load configuration is from an environment variable that points to a file

```
$app->config()->fromEnvVariable('MY_APP_SETTINGS');
```

In this case, before launching the application you have to set the env variable to the file you want to use. On Linux and OSX use the export statement

```
export MY_APP_SETTINGS='/path/to/config/file.php'
```

or somewhere in your app bootstrap phase before constructing the Api instance

```
putenv('MY_APP_SETTINGS=/path/to/config/file.php');
```

- `fromEnvironment( array $variableNames, string $namespace = '', bool $lowercase = true, bool $trim = true ): Configuration`
- `fromJsonFile(string $file): Configuration`
- `fromPhpFile(string $file): Configuration`
- `fromEnvVariable(string $variable): Configuration`
- `fromIniFile(string $file): Configuration`
- `fromObject($object): Configuration`
- `withParameters(array $parameters): Configuration`
- `silent(bool $silent): Configuration`
- `build(string $context): Configuration`

### `Mime`

[](#mime)

- `type(string $extension, int $index = 0): string`
- `types(string $extension): array`
- `supports(string $type): bool`
- `extensions(string $type): array`

### `UUID`

[](#uuid)

Class UUID generates `Universally Unique Identifiers` following the [RFC 4122](http://tools.ietf.org/html/rfc4122).

- `v1(string|null $address = null): string`
- `v3(string $namespace, $name): string`
- `v4(): string`
- `v5(string $namespace, string $name): string`
- `valid(string $uuid): bool`
- `matches(string $uuid, int $version = 4): bool`
- `toBase64(string $uuid): string`
- `fromBase64(string $base64): string`

### `ULID`

[](#ulid)

Class ULID generates `Universally Unique Lexicographically Sortable Identifiers`

- `generate(int $count = 1): self`
- `fromULID(string $ulid): self`
- `fromUUID(string $ulid): self`
- `fromTimestamp(float $timestamp): self`
- `fromDateTime(string $datetime): self`
- `toULID(): array|string`
- `toUUID(): array|string`
- `toDateTime(): array|DateTime`
- `count(): int`
- `valid(string $uuid): bool`

Functions
---------

[](#functions)

```
function arguments(...$values): Argument;
function extended(...$values): ExtendedArguments;
function value(...$values): Data;
function tap(mixed $value, callable|null $callable = null): mixed;
function camel_to_snake_case(string $string): string;
function env(string|null $name = null, mixed $default = null, array|null $initialState = null): mixed;
function error_log(string $function, string $message, $data): void;
function htmlencode(string $input, string $encoding = 'UTF-8'): string;
function is_associative(array $array): bool;
function json_serialize($value, int $options = JSON_PRESERVE_ZERO_FRACTION | JSON_UNESCAPED_SLASHES): string;
function json_unserialize(string $json, bool $associative = false);
function now(): DateTimeImmutable;
function randomstring(int $length = 16, string $prefix = '', string $suffix = ''): string;
function rmdir(string $dirname): bool;
function snake_to_camel_case(string $string): string;
function to_delimited_string(string $string, int $delimiter): string;
function to_kebab_string(string $string): string;
function xml_serialize(string $root, iterable $data): string;
function xml_unserialize(string $xml): array;
```

Code quality
------------

[](#code-quality)

[![Code Coverage](https://camo.githubusercontent.com/df6c669811f793a6f9c42237ca196366098bc7b1d675be418c95b0411d3e60d5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f6465647068702f7374646c69622f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kodedphp/stdlib/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8066bc3682095a1a709955f4bf2ab98ee0f3acc3b7dd3aeb84ab89caa3f7b92c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f6465647068702f7374646c69622f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kodedphp/stdlib/?branch=master)

```
vendor/bin/phpbench run --report=default
vendor/bin/phpunit
```

License
-------

[](#license)

[![Software license](https://camo.githubusercontent.com/b3775a2de17853a90995faa104f941eef3ad3c40cc89e34b8b1eaea014614d4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d425344253230332d2d436c617573652d626c75652e737667)](LICENSE)

The code is distributed under the terms of [The 3-Clause BSD license](LICENSE).

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance53

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 99.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 ~110 days

Recently: every ~202 days

Total

28

Last Release

326d ago

Major Versions

1.9.0 → 2.0.02017-12-26

2.1.0 → 3.0.02018-06-02

3.3.0 → 4.0.02019-05-21

4.0.3 → 5.0.02021-05-03

5.1.1 → 6.0.02022-01-23

PHP version history (7 changes)1.7.0PHP ~7

2.0.1PHP ^7.1.4

4.0.0PHP ^7.3

4.0.1PHP ^7.2

4.0.2PHP ~7.2

5.0.0PHP ^8

6.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/02c41fefd80a09d9f349706dbee9f45b9cfe539509881a05af4fa8d3517a878d?d=identicon)[kodeart](/maintainers/kodeart)

---

Top Contributors

[![kodeart](https://avatars.githubusercontent.com/u/202293?v=4)](https://github.com/kodeart "kodeart (345 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

---

Tags

dtoexceptionsimmutablemimeulidulid-generatorutilityuuiduuid-generatorutilityconfigmimeserializerexceptionsuuiduliddtoimmutablemime-typesdot-arrayuuid generatorulid-generator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koded-stdlib/health.svg)

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

###  Alternatives

[symfony/mime

Allows manipulating MIME messages

2.8k668.8M911](/packages/symfony-mime)[zbateson/mail-mime-parser

MIME email message parser

53949.2M79](/packages/zbateson-mail-mime-parser)[php-mime-mail-parser/php-mime-mail-parser

A fully tested email parser for PHP 8.0+ (mailparse extension wrapper).

9979.6M27](/packages/php-mime-mail-parser-php-mime-mail-parser)[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

5389.8M246](/packages/nette-mail)[zbateson/stream-decorators

PHP psr7 stream decorators for mime message part streams

4748.6M6](/packages/zbateson-stream-decorators)[dflydev/apache-mime-types

Apache MIME Types

701.9M35](/packages/dflydev-apache-mime-types)

PHPackages © 2026

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