jimchen/laravel-macro
Composer 安装命令:
composer require jimchen/laravel-macro
包简介
Laravel Macro Helper
README 文档
README
Laravel Macro Helper
Installing
$ composer require jimchen/laravel-macro -vvv
The package will automatically register itself.
If you use Laravel 5.1.*, you can add the service provider to the providers array in config/app.php.
JimChen\Macro\LaravelMacroServiceProvider::class,
Usage
You should publish the config file to add macros.
$ php artisan vendor:publish --provider="JimChen\Macro\LaravelMacroServiceProvider"
Binding macro class to macroable class in config/macro.php.
return [ 'macros' => [ 'Illuminate\Support\Arr' => [ 'App\Macros\Arr', ] ], ];
Define macro file, app/Macros/Arr1.php.
namespace App\Macro; class Arr { public static function merge($a, $b) { return array_merge($a, $b); } }
Using in anywhere if you need. Great!
For example in app/routes/web.php
use Illuminate\Support\Arr; Route::get('/', function () { $foo = [1, 2]; $bar = [3, 4]; $result = Arr::merge($foo, $bar); dd($result); // [1, 2, 3, 4] });
License
MIT
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-13