PHP code example of jimchen / laravel-macro

1. Go to this page and download the library: Download jimchen/laravel-macro library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jimchen / laravel-macro example snippets


JimChen\Macro\LaravelMacroServiceProvider::class,

return [
    'macros' => [
        'Illuminate\Support\Arr' => [
            'App\Macros\Arr',
        ]
    ],
];

namespace App\Macro;

class Arr
{
    public static function merge($a, $b)
    {
        return array_merge($a, $b);
    }
}

use Illuminate\Support\Arr;

Route::get('/', function () {
    $foo = [1, 2];
    $bar = [3, 4];
    
    $result = Arr::merge($foo, $bar);
    
    dd($result);  // [1, 2, 3, 4]
});
bash
$ php artisan vendor:publish --provider="JimChen\Macro\LaravelMacroServiceProvider"