lambdish/phunctional
Composer 安装命令:
composer require lambdish/phunctional
包简介
λ PHP functional library
README 文档
README
Phunctional, because functional programming matters.
Lambdish's Phunctional is a little library that tries to bring to PHP some aspects of functional programing with util high order functions and functions for manage iterables.
About
Phunctional is heavily inspired by Clojure and some other PHP libraries like iter, compose and felpado.
The main principles that we have in mind developing this library are:
- A collection can be any iterable PHP object, arrays or generators
- Favor composition vs inheritance
- Be lazy when you can
- Avoid state, state is (usually) evil!
- Simplicity over easiness
- Break the above rules if it makes sense
All of this can be resumed with a word: Immutability.
Installation
To install it with composer:
composer require lambdish/phunctional
Simple usage
The first is to import every function you're going to use, for example:
use function Lambdish\phunctional\map;
And then you'll be able to use it:
map( function ($number) { return $number + 10; }, [1, 2, 3, 4, 5] ); // => [11, 12, 13, 14, 15]
And do something more complex like:
use function Lambdish\Phunctional\pipe; use const Lambdish\Phunctional\{filter_null, reverse, first}; $lastNonNullableValue = pipe(filter_null, reverse, first); $lastNonNullableValue(['first', null, 'other', 'last non nullable', null, null]); // => "last non nullable"
Here we're using the provided constants, that acts like an alias for the functions full qualified namespace
(and therefore, are callable).
Documentation
You can find the functions documentation here.
lambdish/phunctional 适用场景与选型建议
lambdish/phunctional 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.1M 次下载、GitHub Stars 达 362, 最近一次更新时间为 2016 年 09 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「php」 「library」 「functional」 「lambda」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lambdish/phunctional 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lambdish/phunctional 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lambdish/phunctional 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
Alfabank REST API integration
统计信息
- 总下载量: 2.1M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 364
- 点击次数: 9
- 依赖项目数: 25
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-12
