wegnermedia/commander

Simple Command Handler Support
15 1
Install
composer require wegnermedia/commander
Latest Version:1.0.1
PHP:>=5.4.0
Last Updated:Jul 22, 2014
Links: GitHub  ·  Packagist
Maintainer: wegnermedia

Laravel Command Bus Service

This Package gives you an easy way to throw Commands in a Command Bus.

Installation

Per usual, install Commander through Composer.

"require": {
    "wegnermedia/commander": "dev-master"
}

Next, update app/config/app.php to include a reference to this package's service provider in the providers array.

'providers' => [
    'Wegnermedia\Commander\CommanderServiceProvider'
]

Next, add the facade app/config/app.php.

'aliases' => [
    'Commander' => 'Wegnermedia\Commander\Facades\Commander'
]

And now build something awesome.

Usage via Trait

<?php

use Wegnermedia\Commander\CommanderTrait;

class CartController extends ShopController {

	use CommanderTrait;

	/**
	 * Add Item to Cart.
	 *
	 * @return Response
	 */
	public function addItem()
	{
		$inputs = Input::all();

		// Validation goes here ...

		$command = new AddItemToCartCommand($inputs);

		$result = $this->execute($command);

		// ... create the Response
	}
}

Usage via Facade

<?php

class CartController extends ShopController {

	/**
	 * Add Item to Cart.
	 *
	 * @return Response
	 */
	public function addItem()
	{
		$inputs = Input::all();

		// Validation goes here ...

		$command = new AddItemToCartCommand($inputs);

		$result = Commander::execute($command);

		// ... create the Response
	}
}

Done!

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

404,034,618 608
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

387,976,821 4,658