PHPackages                             laraviet/commander - 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. [Framework](/categories/framework)
4. /
5. laraviet/commander

ActiveLibrary[Framework](/categories/framework)

laraviet/commander
==================

Commands and domain events in Laravel

2.0(11y ago)017MITPHPPHP &gt;=5.4.0

Since Dec 10Pushed 11y ago2 watchersCompare

[ Source](https://github.com/laraviet/Commander)[ Packagist](https://packagist.org/packages/laraviet/commander)[ RSS](/packages/laraviet-commander/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (3)Used By (0)

Laravel Commander
=================

[](#laravel-commander)

This package gives you an easy way to leverage commands and domain events in your Laravel projects.

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

[](#installation)

Per usual, install Commander through Composer.

```
"require": {
    "laraviet/commander": "~2.*"
}
```

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

```
'providers' => [
    'Laracasts\Commander\CommanderServiceProvider'
]
```

Usage
-----

[](#usage)

Easily, the most important piece of advice I can offer is to keep in mind that this approach isn't for everything. If you're building a simple CRUD app that does not have much business logic, then you likely don't need this. Still want to move ahead? Okay - onward!

### The Goal

[](#the-goal)

Imagine that you're building an app for advertising job listings. Now, when an employer posts a new job listing, a number of things need to happen, right? Well, don't put all that stuff into your controller! Instead, let's leverage commands, handlers, and domain events to clean up our code.

### The Controller

[](#the-controller)

To begin, we can inject this package's `CommanderTrait` into your controller (or a BaseController, if you wish). This will give you a couple helper methods to manage the process of passing commands to the command bus.

```
