PHPackages                             laracasts/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. laracasts/commander

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laracasts/commander
===================

Commands and domain events in Laravel

1.4.3(11y ago)277405.0k↑105.2%64[14 issues](https://github.com/laracasts/Commander/issues)[8 PRs](https://github.com/laracasts/Commander/pulls)8MITPHPPHP &gt;=5.4.0

Since Jun 28Pushed 11y ago19 watchersCompare

[ Source](https://github.com/laracasts/Commander)[ Packagist](https://packagist.org/packages/laracasts/commander)[ RSS](/packages/laracasts-commander/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (5)Versions (24)Used By (8)

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

[](#laravel-commander)

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

> Laravel 5 users: this package is no longer required, as the framework includes its own flexible command bus out of the box.

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

[](#installation)

Per usual, install Commander through Composer.

```
"require": {
    "laracasts/commander": "~1.0"
}
```

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.

```
