PHP code example of wegnermedia / commander

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

    

wegnermedia / commander example snippets


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

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



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
	}
}



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
	}
}