Composite: Compose objects into tree structures to represent part–whole hierarchies, letting clients treat individual objects and compositions uniformly. The Composite pattern lets you treat a group of objects the same way as a single object. A tree of items, where each item can contain other items, is handled through one shared interface.
Think of a menu with submenus, a folder with files and subfolders, or a product bundle that contains products and smaller bundles. Asking the top item for its price or size works the same whether it is one product or a deeply nested bundle.
What should you keep in mind with Composite?
In code, every node implements the same method, such as getPrice(). A leaf returns its own value; a composite adds up the values of its children. The calling code does not need to know which kind it has. This removes many if checks and makes recursive structures much easier to work with.
Apply Spatie's Laravel and PHP coding standards for any task that creates, edits, reviews, refactors, or formats Laravel/PHP code or Blade templates; use for controllers, Eloquent models, routes, config, validation, migrations, tests, and related files to align with Laravel conventions and PSR-12.
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.