PHP code example of elber / laravel-clean-architecture
1. Go to this page and download the library: Download elber/laravel-clean-architecture 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/ */
elber / laravel-clean-architecture example snippets
use Src\Billing\Application\Commands\CreateInvoice\{CreateInvoiceCommand, CreateInvoiceHandler};
use Src\Billing\Domain\Events\InvoiceCreatedEvent;
use Src\Billing\Infrastructure\InMemoryInvoiceWriteRepository;
test('creating an invoice persists it and records the creation event', function () {
$repository = new InMemoryInvoiceWriteRepository;
(new CreateInvoiceHandler($repository))->handle(new CreateInvoiceCommand('inv-1', []));
$invoice = $repository->ofId('inv-1');
expect($invoice)->not->toBeNull()
->and($invoice->releaseEvents()[0])->toBeInstanceOf(InvoiceCreatedEvent::class);
});