O'Reilly logo

Mastering Laravel by Christopher John Pecoraro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Building Services, Commands, and Events

In the first two chapters, we set up the basic structure of our accommodation reservation system. We designed our classes, created our database schema, and learned how to test them. Now we need to translate the business requirements into code.

In this chapter, we will cover the following topics:

  • Commands
  • Events
  • Command handlers
  • Event handlers
  • Queued event handlers
  • Queued commands
  • Console commands
  • The command scheduler

Request routing

As mentioned earlier, Laravel 5 has adopted the command bus pattern. Laravel 4 viewed commands as something to be executed from the command line, whereas in Laravel 5, a command can be used in any context, allowing excellent reuse of code.

The following is an example of the Laravel ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required