php

A reference for modern PHP 8.5 development, covering language features, application structure, security, asynchronous work, testing, and developer tools.

In plain words
What is it for?
It guides writing and reviewing PHP code, including type declarations, object-oriented design, immutable data objects, runtime configuration, architecture, security, testing, and tooling.
Why use it?
It helps developers avoid unsupported PHP versions, weak typing, unsafe practices, and unsuitable performance settings.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/sumonmselim/agentguard/php
Any agent
npx skills add SumonMSelim/agentguard --skill php
Clone the repo
git clone --depth 1 https://github.com/SumonMSelim/agentguard

Made for: Claude Code, Codex.

Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,457 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00034 $0.01457
Opus 5 $0.00017 $0.00728
Sonnet 5 $0.00007 $0.00291
Haiku 4.5 $0.00003 $0.00146

Measured 2d ago against content hash 30967c0418b2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

php scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/php/SKILL.md · 91 lines

How it starts

The opening of the file, as written. The whole thing — 91 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PHP

Runtime and versioning

  • Run PHP 8.4 (active support) or 8.5 (latest stable). Never run EOL versions — no security patches
  • declare(strict_types=1) at top of every file
  • OPcache enabled in production. opcache.preload for warm startup on 8.0+
  • JIT enabled for CPU-bound workloads: opcache.jit=tracing, opcache.jit_buffer_size=128M. Not beneficial for typical I/O-bound web apps — benchmark before enabling

Type system

  • Type-hint all parameters, return types, and properties. No mixed — use union types (int|string) or generics via PHPDoc
  • never return type for functions that always throw or exit
  • readonly properties for value objects and DTOs (8.1+). readonly classes (8.2+) for fully immutable objects
  • Asymmetric visibility (8.4+): public private(set) for properties readable everywhere but writable only within class
  • Property hooks (8.4+): get/set hooks on properties — eliminates getter/setter boilerplate. Incompatible with readonly
  • Intersection types (8.1+): Countable&Iterator. DNF types (8.2+): (A&B)|null
  • Typed class constants (8.3+): const string VERSION = '1.0'
  • #[Override] attribute (8.3+) on overriding methods — compiler-checked safety net
  • Enums over constants for closed value sets (8.1+). Backed enums (string/int) for serialisation
  • Named arguments for multi-param functions with non-obvious order. Not for all calls
  • match over switch — exhaustive, no fall-through, returns value
  • First-class callable syntax (8.1+): strlen(...) over Closure::fromCallable('strlen')

Modern syntax (8.4–8.5)

  • new without parentheses for chaining (8.4+): new Collection()->filter()->map()
  • Pipe operator (8.5+): $result = $value |> trim(...) |> strtolower(...) |> htmlspecialchars(...). Prefer over nested calls
  • clone with (8.5+): $new = clone $obj with {name: 'updated'}. Preferred over manual clone + property set
  • Static property asymmetric visibility (8.5+): same syntax as instance properties
  • Lazy objects (8.4+): built-in lazy initialisation via ReflectionClass::newLazyProxy(). Use for expensive dependencies in DI containers
  • Driver-specific PDO classes (8.4+): Pdo\Mysql, Pdo\Pgsql, Pdo\Sqlite — type-safe, IDE-friendly alternatives to generic PDO

Read the full file on GitHub · 91 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 91 lines · 0 tokens per session scan A 30967c0418b2

Subscribe to this mod's changes

php is a skill published in the GitHub repository SumonMSelim/agentguard (56 stars, last pushed 1mo ago), licensed MIT. It adds 34 tokens to every session and 1,457 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.