1. Go to this page and download the library: Download lyhty/macronite 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/ */
lyhty / macronite example snippets
namespace App\Providers;
use Lyhty\Macronite\MacroServiceProvider as ServiceProvider;
class MacroServiceProvider extends ServiceProvider
{
protected static array $macros = [
\Illuminate\Support\Collection::class => [
'example' => \App\Macros\ExampleMacro::class,
\App\Macros\SecondExampleMacro::class,
]
];
}
namespace App\Macros;
class ExampleMacro
{
public function __invoke(): \Closure
{
return function () {
// Something cool worth getting macroed happens here...
return $this;
}
}
}
namespace App\Providers;
use Lyhty\Macronite\MacroServiceProvider as ServiceProvider;
class MacroServiceProvider extends ServiceProvider
{
protected static array $macros = [
\Illuminate\Support\Collection::class => [
'example' => \App\Macros\ExampleMacro::class,
]
];
}