PHPackages                             smgladkovskiy/querier - 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. smgladkovskiy/querier

ActiveLibrary

smgladkovskiy/querier
=====================

Queries for Command-Query Separation Principle in Laravel

1.1.0(11y ago)1136MITPHPPHP &gt;=5.4.0

Since Oct 22Pushed 11y ago1 watchersCompare

[ Source](https://github.com/smgladkovskiy/querier)[ Packagist](https://packagist.org/packages/smgladkovskiy/querier)[ RSS](/packages/smgladkovskiy-querier/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (4)Used By (0)

Laravel Querier
===============

[](#laravel-querier)

This package gives you an easy way to leverage queries for Command-Query Separation Principle in your Laravel projects.

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

[](#installation)

Per usual, install Querier through Composer.

```
"require": {
    "smgladkovskiy/querier": "~1.0"
}
```

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

```
'providers' => [
    'SMGladkovskiy\Querier\QuerierServiceProvider'
]
```

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 analysing of job advertisements. When you make pages with massive reports, many work is done to prepare data to be shown, right? Well, don't put all that stuff into your controller! Instead, let's leverage queries and handlers to clean up our code.

### The Controller

[](#the-controller)

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

```
