PHPackages                             nunomaduro/curryable - 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. nunomaduro/curryable

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

nunomaduro/curryable
====================

An elegant and simple curry(f) implementation in PHP.

1752.2k↓75%3PHP

Since Nov 21Pushed 4y ago5 watchersCompare

[ Source](https://github.com/nunomaduro/curryable)[ Packagist](https://packagist.org/packages/nunomaduro/curryable)[ RSS](/packages/nunomaduro-curryable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

 [![Curryable](https://raw.githubusercontent.com/nunomaduro/curryable/master/docs/example.png)](https://raw.githubusercontent.com/nunomaduro/curryable/master/docs/example.png)

 [![Build Status](https://camo.githubusercontent.com/c5cb1b3250c8d4dc814a360657c724ba9cfe56424d203b78c752aeb0faa7947a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6e756e6f6d616475726f2f637572727961626c652f6d61737465722e737667)](https://travis-ci.org/nunomaduro/curryable) [![Total Downloads](https://camo.githubusercontent.com/0987d4fcfbe3df0e7dad87c8bf3ee4a33bb4be56b2d63dfa2bed2b52c3c5f6e8/68747470733a2f2f706f7365722e707567782e6f72672f6e756e6f6d616475726f2f637572727961626c652f642f746f74616c2e737667)](https://packagist.org/packages/nunomaduro/curryable) [![Latest Version](https://camo.githubusercontent.com/81255497e7d99788da13a6e4917800c0adfdb30e4e08bf3f35c8f9db24093bfe/68747470733a2f2f706f7365722e707567782e6f72672f6e756e6f6d616475726f2f637572727961626c652f762f737461626c652e737667)](https://packagist.org/packages/nunomaduro/curryable) [![License](https://camo.githubusercontent.com/0ef62fc026c50f27bccade019582531718b396328d1241358fc910b79b5d85d0/68747470733a2f2f706f7365722e707567782e6f72672f6e756e6f6d616475726f2f637572727961626c652f6c6963656e73652e737667)](https://packagist.org/packages/nunomaduro/curryable)

About Curryable
---------------

[](#about-curryable)

**This package is under development, please don't use it on production and wait for the stable release!**

Curryable was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is an elegant and simple **curry(f)** implementation in PHP. Currying is an advanced technique of working with functions. It **wraps the given expressions and arguments into a new function** that resolves a value.

Installation &amp; Usage
------------------------

[](#installation--usage)

> **Requires [PHP 7.2+](https://php.net/releases/)**

Create your package using [Composer](https://getcomposer.org):

```
composer require nunomaduro/curryable
```

This helper usage is best described through example in the [Laravel](https://laravel.com) framework:

### On routing

[](#on-routing)

```
Route::get('/', curry('view', 'welcome'));

// Instead of
Route::get('/', function () {
    return view('welcome');
});
```

```
Route::get('user/{id}', curry(User::class)->find());
// Or with Eloquent macro
Route::get('user/{id}', User::curry()->find());

// Instead of
Route::get('user/{id}', function ($id) {
    return User::find($id);
});
```

### On macros

[](#on-macros)

Renaming the `lower` method to `toLower`:

```
Str::macro('toLower', curry()->lower());
// or with the global `strtolower`
Str::macro('toLower', curry('strtolower'));

// Instead of
Str::macro('toLower', function ($value) {
    return Str::lower($value);
});
```

### On collections

[](#on-collections)

Using the global `strtoupper`:

```
$collection = collect(['nuno'])->map(curry('strtoupper')); // ['NUNO']

// Instead of
$collection = collect(['nuno'])->map(function ($name) {
    return strtoupper($name);
});
```

Here is another example using the `each`:

```
// Calls User::create($user) foreach user
collect($users)->each(User::curry()->create());

// Instead of
$collection = collect($users)->map(function ($user) {
    return User::create($user);
});
```

### Dispatching jobs:

[](#dispatching-jobs)

```
dispatch(curry(Artisan::class)->call('horizon:terminate'));

// Instead of
dispatch(function () {
    Artisan::call('horizon:terminate');
});
```

### Curry on class instance methods

[](#curry-on-class-instance-methods)

With global helper:

```
$closure = curry($instance)->instanceMethodName();
$closure($first, $second);

$closure = curry($instance)->instanceMethodName($first);
$closure($second); // just need for the second argument

$closure = curry($instance)->instanceMethodName($first, $second);
$closure(); // no need for arguments
```

With trait `NunoMaduro\Curryable\Curryable`:

```
$closure = $instance->curry()->instanceMethodName();
$closure($first, $second);

$closure = $instance->curry()->instanceMethodName($first);
$closure($second); // just need for the second argument

$closure = $instance->curry()->instanceMethodName($first, $second);
$closure(); // no need for arguments
```

### Curry on class static methods

[](#curry-on-class-static-methods)

```
// Curry on instance methods
$closure = curry(Instance::class)->staticMethodName();
$closure($first, $second);

$closure = curry(Instance::class)->staticMethodName($first);
$closure($second); // just need for the second argument

$closure = curry(Instance::class)->staticMethodName($first, $second);
$closure(); // no need for arguments
```

### Curry on functions

[](#curry-on-functions)

```
// Curry on instance methods
$closure = curry('function_name');
$closure($first, $second);

$closure = curry('function_name', $first);
$closure($second); // just need for the second argument

$closure = curry('function_name', $first, $second);
$closure(); // no need for arguments
```

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

[](#contributing)

Thank you for considering to contribute to *Curryable*. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).

You can have a look at the [CHANGELOG](CHANGELOG.md) for constant updates &amp; detailed information about the changes. You can also follow the twitter account for latest announcements or just come say hi!: [@enunomaduro](https://twitter.com/enunomaduro)

Support the development
-----------------------

[](#support-the-development)

**Do you like this project? Support it by donating**

- Github sponsors: [Donate](https://github.com/sponsors/nunomaduro)
- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L)
- Patreon: [Donate](https://www.patreon.com/nunomaduro)

License
-------

[](#license)

curryable is an open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/86cfef5c1f5195df1a9db17a5f8ecb34455e1f0133a725de9acf7f2fb26ac6a1?d=identicon)[nunomaduro](/maintainers/nunomaduro)

---

Top Contributors

[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (19 commits)")

---

Tags

curryfunctional-programminglaravelphp

### Embed Badge

![Health badge](/badges/nunomaduro-curryable/health.svg)

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

###  Alternatives

[funct/funct

A PHP library with commonly used code blocks

605141.2k75](/packages/funct-funct)[imanghafoori/laravel-terminator

A minimal yet powerful package to give you opportunity to refactor your controllers.

25353.0k](/packages/imanghafoori-laravel-terminator)[hanson/chinese

简繁体转换.

2317.0k](/packages/hanson-chinese)[maisondunet/module-gtm-cookie-consent

A simple cookie consent module for magento. It relies on new GTM consent functionality.

134.5k](/packages/maisondunet-module-gtm-cookie-consent)

PHPackages © 2026

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