PHP code example of php-ddd / command

1. Go to this page and download the library: Download php-ddd/command 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/ */

    

php-ddd / command example snippets


// configuration
$handler = new AddItemToChartCommandHandler();
$locator = new CommandHandlerLocator();
$locator->register('AddItemToChartCommand', $handler);

$bus = new SequentialCommandBus($locator);

// usage
$command = new AddItemToChartCommand($item, $chart);
$bus->dispatch($command); // internally, the bus will call the corresponding handler.