© Kelt Dockins 2017

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

11. Composite

Kelt Dockins

(1)Dolph, Arkansas, USA

$> git checkout composite

Intent

Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.1

Applications

A lot of things in life have a hierarchical structure : family trees, relationships, organizations, language, nature, military, government, addresses, workplace, games, file structure, and much more. Sometimes things are easier to think about in hierarchies. Imagine trying to try explain your family tree using only first names. Hierarchies allow us to take a complex system and break it down into related ...

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.