基于 Laravel collect 的 PHP Extension
介绍:
vcollect 是一个PHP c extension,提供流畅、便利的数组数据操作。
安装:
1、Clone
定位于PHP下的ext目录,执行
git clone https://github.com/VikinDev/v-collect.git
2、编译安装
在扩展目录内,执行
phpize
./configure
make && make install
3、修改ini
在php.ini文件中加入extension = vcollect.so
使用
创建集合
$test = vcollect([1, 2, 3, 4, 5, 6]);
可用方法
| ^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ | ^_^ |
|---|---|---|---|---|---|---|---|---|---|
| map | collapse | avg | has | mx | mi | toJson | toArray | take | pluck |
| where |
where
快速过滤或筛选集合
$vcollect = vcollect([
['developer' => ['name' => 'Taylor', 'option' => ['test' => 'one'] ] ],
['developer' => ['name' => 'Abigail', 'option' => ['test' => 'two'] ] ]
]);
$vcollect->where('developer.option.test', 'one')->toArray();
// ['developer' => ['name' => 'Taylor', 'option' => ['test' => 'one'] ] ]
......
github: https://github.com/VikinDev/v-collect
:relaxed:
欢迎各位star,我会继续努力!向各位大佬学习;:clap:
本帖已被设为精华帖!
本帖由 Summer
于 9年前 加精
关于 LearnKu
做成了php的扩展库?:+1:
@vikin https://github.com/Vikins/vcollect 这个也是你开源的么。
一般 laravel 外的项目,使用 collection 的话都会直接 composer 载入 illuminate/support。现在整成扩展,也是很棒的想法,加油!:thumbsup: :blush:
@camry 是的 :bowtie:
哈哈,有人做了,感谢啊
PHP 扩展的开发文档是官网上的那个吗?
@chongyi 看过部分,不过好多都是看源码学来的;
@vikin 我不知道从何下手,官网的扩展编写部分,无论是中文的还是英文的,都不全。参考资料并不丰富,很多都很旧,新的 PHP 7 的 zval 结构变动了,还没研究,好累
@chongyi 可以看一下你经常用的函数源码(因为你已经很熟悉该函数的特性),这样理解起来比较快;对ZEN_API也会了解一些;
@vikin 要得!谢谢
@vikin 话说这个 windows 上编译通过没?
@chongyi :smile:谢谢大佬支持;
@vikin 我离大佬还早,现在是光会写 PHP,还不会写 PHP :joy:
@chongyi 抱歉,身边没有windows机子,还没在windows上编译过,不过config.w32是可用的,:simple_smile: 编译成功烦请大佬告知;
@vikin 我现在也没得 windows 的机子。。。 :joy:
而且php 扩展运行的速度回更快,厉害
@大帅 :smile:谢谢大佬!
支持一下