PHPackages                             eps90/req2cmd-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. eps90/req2cmd-bundle

ActiveSymfony-bundle

eps90/req2cmd-bundle
====================

Extract command from a HTTP request and send it to the command bus like Tactician

v1.0.0-rc8(8y ago)2154[5 issues](https://github.com/eps90/req2cmd-bundle/issues)MITPHPPHP &gt;=7.1

Since Jul 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/eps90/req2cmd-bundle)[ Packagist](https://packagist.org/packages/eps90/req2cmd-bundle)[ RSS](/packages/eps90-req2cmd-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (8)Dependencies (8)Versions (9)Used By (0)

Req2Cmd Bundle
==============

[](#req2cmd-bundle)

Extract command from a HTTP request and send it to the command bus, like [Tactician](http://tactician.thephpleague.com/).

[![Latest Stable Version](https://camo.githubusercontent.com/2c580bb00705a65d9b6b7e791a873f9317309b272afa476c872b7af1b0324db4/68747470733a2f2f706f7365722e707567782e6f72672f65707339302f72657132636d642d62756e646c652f762f737461626c65)](https://packagist.org/packages/eps90/req2cmd-bundle)[![Latest Unstable Version](https://camo.githubusercontent.com/1af83b70d16eea6c1c702517653de271712803c35f1a3f8bfd8b195525afbb7b/68747470733a2f2f706f7365722e707567782e6f72672f65707339302f72657132636d642d62756e646c652f762f756e737461626c65)](https://packagist.org/packages/eps90/req2cmd-bundle)[![License](https://camo.githubusercontent.com/e88f1c33ff39b8862f23d761e7cc08edc3c777ffe994fd48479c832e966de70f/68747470733a2f2f706f7365722e707567782e6f72672f65707339302f72657132636d642d62756e646c652f6c6963656e7365)](https://packagist.org/packages/eps90/req2cmd-bundle)

[![Build Status](https://camo.githubusercontent.com/a6535d686a4bd3d668b083c82884edf1568a6bef82ab77c4146ec8c2167e395c/68747470733a2f2f7472617669732d63692e6f72672f65707339302f72657132636d642d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/eps90/req2cmd-bundle)[![Coverage Status](https://camo.githubusercontent.com/81323e409b80fb00853fc6798e56226974604c2cb2b39a0e522eff4b245fc4f5/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f65707339302f72657132636d642d62756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/eps90/req2cmd-bundle?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/11225af09a87279669a17f92696253e153ca288009f116c859b6239ef6d404ca/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f65707339302f72657132636d642d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/eps90/req2cmd-bundle/?branch=master)[![Codacy Badge](https://camo.githubusercontent.com/363691962884b2183687f5b48c0caf478ca8d50fcf5fd1784e271d9388c5e3f1/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3431336537623431623738373464383138323636616336363866346564643932)](https://www.codacy.com/app/eps90/req2cmd-bundle?utm_source=github.com&utm_medium=referral&utm_content=eps90/req2cmd-bundle&utm_campaign=Badge_Grade)

[![SensioLabsInsight](https://camo.githubusercontent.com/6c83bf5bcfdbf999f7c5407b900e025b87c1b8c34c0a085f2613a5151fcf0282/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f65636333343065392d646561622d343764612d393238632d6233306333383464663635342f6269672e706e67)](https://insight.sensiolabs.com/projects/ecc340e9-deab-47da-928c-b30c384df654)

Motivation
----------

[](#motivation)

Recently I've been writing some project with framework-agnostic code with [CQRS](https://martinfowler.com/bliki/CQRS.html) approach so I could have all use cases in separate classes written in clean and readable way. When I started to integrate it with [Symfony](http://symfony.com) framework I've noticed that each controller's action looks the same: create command from request, send to the command bus and return `Response` from action.

I've created this library to facilitate converting requests to commands and automatically sending them to the command bus, like [Tactician](http://tactician.thephpleague.com/). Thanks to **Symfony Router** component and **Symfony Event Dispatcher** with kernel events listeners an application is able to recognize command from route parameters and convert to the command instance, all thanks to this bundle.

This bundle **works** and is ready to use. However it may need some work to be adaptable to each case. I hope that completely framework-agnostic code will be available soon so you'll be able to use it with whatever framework you like. There's still need to separate from Symfony's Request class and use PSR7's `RequestInterface` implementations. Support for other command buses is also a nice-to-have. Every contribution is welcome!

Requirements
------------

[](#requirements)

- **PHP** 7.1+
- **Symfony Framework Bundle** (or Symfony Standard Edition) - 2.3+|3.0+

Optionally, depending on usage, you may need:

- **Tactician bundle** 0.4+
- **Symfony Serializer** (bundled with Symfony Framework bundle)

Installation
------------

[](#installation)

**Step 1:** Open a command console, enter your project's root director and run following command to install the package with Composer:

```
composer require eps90/req2cmd-bundle
```

**Step 2:** Enable the bundle by adding it to the list of registered bundles in the `app/AppKernel.php` file:

```
