---
title: "PHP Patterns"
description: "> This file extends the common patterns rule with PHP specific content."
type: skill
canonical_url: https://claudary.paisolsolutions.com/skills/php-patterns
source: "Claudary"
difficulty: intermediate
author: "Claude Code Knowledge Pack"
date: 2026-07-10T11:31:58.508Z
license: CC-BY-4.0
attribution: "PHP Patterns — Claudary (https://claudary.paisolsolutions.com/skills/php-patterns)"
---

# PHP Patterns
> This file extends the common patterns rule with PHP specific content.

## Overview

---
description: "PHP patterns extending common rules"
globs: ["**/*.php", "**/composer.json"]
alwaysApply: false
---
# PHP Patterns

> This file extends the common patterns rule with PHP specific content.

## Thin Controllers, Explicit Services

- Keep controllers focused on transport: auth, validation, serialization, status codes.
- Move business rules into application/domain services that are easy to test without HTTP bootstrapping.

## DTOs and Value Objects

- Replace shape-heavy associative arrays with DTOs for requests, commands, and external API payloads.
- Use value objects for money, identifiers, and constrained concepts.

## Dependency Injection

- Depend on interfaces or narrow service contracts, not framework globals.
- Pass collaborators through constructors so services are testable without service-locator lookups.

---

Source: [Claudary](https://claudary.paisolsolutions.com/skills/php-patterns) · https://claudary.paisolsolutions.com
