GithubHelp home page GithubHelp logo

commandbus's Introduction

CommandBus Base

This package provides an opinionated base to get started using the Command Bus architecture in PHP. Most of what's here has been derived from code and discussions with @ShawnMcCool. The structure may not fit with everyone's definitions of how a Command Bus should be implemented, however it provides a path of little resistance for newcomers.

Um.. wat

If you're unfamiliar with Command Bus style architecture I urge you to check out a talk that @ShawnMcCool gave at Laracon 2014. Another great resource on learning the concepts and reasons for this style of architecture is a series at Laracasts called Commands and Domain Events. For more advance reading and learning, check out Mathias Verraes' website.

Buses

This package comes by default with:

  • ExecutionBus
  • ValidationBus
  • LoggingBus

How you stack them is up to you, however the ExecutionBus must come last to deliver the request to the final handle() call.

If you would like an example of how the buses are instantiated, check the service provider's register() included in the source here.

Laravel Service Provider

If you wish to integrate the commandbus with Laravel, there is one provided. You can simply add it to your providers array in app/config/app.php and start injecting the CommandBus\CommandBus interface into your controllers and classes.

'CommandBus\CommandBusServiceProvider',

Note: The execution order of the busses is:Request -> LoggingBus -> ValidationBus -> ExecutionBus -> Handler. If you wish to re-arrange the bus execution order, by all means make your own service provider and reorganize them. You could even write your own bus if you wanted.

Example Request Cycle

To set up an example request cycle, we simply need a request object and handler and response objects to match.

Examples can be found in the examples directory.

commandbus's People

Contributors

jesseobrien avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hardevine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.