PHP code example of maximecolin / car

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

    

maximecolin / car example snippets


class CreateArticleCommand implements CommandInterface
{
	public $title;
	public $content;
	
	public function __construct($title, $content)
	{
		$this->title   = $title;
		$this->content = $content;
	}
}

class CreateCommandHandler implements CommandHandlerInterface
{
	public function handle(CommandInterface $command)
	{
		// Place here you domain code which create an article ...
	}
}

// Usually, have a service to get the bus
$bus = new CommandBus();
$bus->addResolver(new ClassNameResolver());

$command = new CreateArticleCommand('My article name', 'My article content');

$bus->execute($command);