PHP code example of edykim / laravel-container-helper
1. Go to this page and download the library: Download edykim/laravel-container-helper 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/ */
edykim / laravel-container-helper example snippets
use function Edykim\LaravelContainerHelper\Support\instance;
// ...
$app->bind(
CalculatorInterface::class,
instance(CalculatorInterface::class)
->lazy(HeavilyLoadedCalculator::class)
);
use function Edykim\LaravelContainerHelper\Support\instance;
// ...
$app->bind(
CalculatorInterface::class,
instance(CalculatorInterface::class)
->sequence(
SimpleProductCalculator::class,
DigitalProductCalculator::class,
ShippingChargeCalculator::class,
)
);
class HasDigitalProducts {
public function check(Cart $cart): bool {
// ...
}
}
use function Edykim\LaravelContainerHelper\Support\instance;
// ...
$app->bind(
CalculatorInterface::class,
instance(CalculatorInterface::class)
->when(
HasDigitalProduct::class,
DigitalProductCalculator::class,
SimpleProductCalculator::class,
)
);