© Kelt Dockins 2017

Kelt Dockins, Design Patterns in PHP and Laravel, 10.1007/978-1-4842-2451-9_17

17. Command

Kelt Dockins

(1)Dolph, Arkansas, USA

$> git checkout command

Intent

Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. 1

Applications

When you need to decouple an object that performs an action from an object that invokes an action, this is a good pattern to use. What does that last part really mean, though? Suppose you want to queue up a list of events that all do various different things. Later you will purge the queue, which will actually invoke all of those actions. Why would you not just invoke/perform the action immediately? There ...

Get Design Patterns in PHP and Laravel now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.