PHP code example of lachezargrigorov / laravel-closures-container

1. Go to this page and download the library: Download lachezargrigorov/laravel-closures-container 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/ */

    

lachezargrigorov / laravel-closures-container example snippets


Lachezargrigorov\ClosuresContainer\ClosuresContainerServiceProvider::class,

"Closures" => Lachezargrigorov\ClosuresContainer\Facades\Facade::class,
 php

//using Facades

Closures::register("sumTwoNumbers",function($a,$b)
{
return $a + $b;
});

$sum = Closures::sumTwoNumbers(1,2); //3

$bool = Closures::isRegistered("sumTwoNumbers");

//using IOC

$closures = app("closures");

$closures->register("sumTwoNumbers",function($a,$b)
{
return $a + $b;
});

$sum = $closures->sumTwoNumbers(1,2); //3

$bool = $closures->isRegistered("sumTwoNumbers");