PHPackages                             samuelludwig/phprelude - 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. samuelludwig/phprelude

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

samuelludwig/phprelude
======================

The standard library I wish PHP always had

0.2.1(4y ago)244[1 issues](https://github.com/samuelludwig/phprelude/issues)MITPHPPHP &gt;=7.4 || &gt;=8.0

Since Jun 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/samuelludwig/phprelude)[ Packagist](https://packagist.org/packages/samuelludwig/phprelude)[ RSS](/packages/samuelludwig-phprelude/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

Phprelude
=========

[](#phprelude)

The standard library I wish PHP always had.

Significant credit belongs to [leocavalcante/Siler](https://github.com/leocavalcante/Siler), whose `Functional` library has been largely transplanted into this project, and who, in addition, has made programming in PHP bearable for me and other FP zealots.

Usage
-----

[](#usage)

### Composer

[](#composer)

Install via

```
composer install "samuelludwig/phprelude"
```

And then autoload the library namespaces via the typical

```
require_once __DIR__ . '/path/to/vendor/autoload.php';
```

### Manual Install + Require

[](#manual-install--require)

If you opt to add the library as a submodule to your project, you can conveniently require all files in the library by using the `autoload.php` file a la

```
require_once __DIR__ . '/path/to/Phprelude/autoload.php';
```

Modules
-------

[](#modules)

The modules breakdown as follows:

- Core: Suitable primatives for FP tools
- Enum: Functions for processing and manipulating "Enumerables" (Arrays)
- Io: Functions for I/O
- Math: Math-related functions
- Natural: Integer-related functions
- Str: String-related functions
- File: File-related functions
- Environment: Environment-variable-related functions
- Json: JSON-related functions

Notable Features
----------------

[](#notable-features)

### Piping!

[](#piping)

Users of Elixirs wonderful `|>` operator or the threading macro `->` found in most lisps should be very familar with the concept of this function.

Graciously taken verbatim from Siler is the indespensible `pipe`. Few things make my eyes glaze over as much as nested function calls and intermediate variables: this is where `Core\pipe` comes to the rescue!

We can supply `pipe` with a list of callbacks which each expect one argument, and as a result we will receive a lambda, which will feed the output of each callback into the next one in the list, and finally returning the output of the last callback.

Here's an example:

```
