php-best-practices

php-best-practices is a skill for Claude Code, Codex from AsyrafHussin/agent-skills. It costs 64 tokens per session (2,212 once invoked), scanned A, original, MIT.

A set of guidelines for writing PHP 8.x code using common PHP standards and object-oriented design principles such as SOLID.

In plain words
What is it for?
It is for reviewing PHP code, checking types, applying PSR standards, assessing code quality, and choosing patterns that match the project's PHP version.
Why use it?
It helps identify code that may be unsafe, hard to maintain, or incompatible with the PHP version used by the project.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

not rated 74repo +2 12d ago A scan Socket: passSnyk: passSkillSpector: pass 64 tokens original MIT

Good fit It is for reviewing PHP code, checking types, applying PSR standards, assessing code quality, and choosing patterns that match the project's PHP version.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/asyrafhussin/agent-skills/php-best-practices
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.

Any agent
npx skills add AsyrafHussin/agent-skills --skill php-best-practices
Clone the repo
git clone --depth 1 https://github.com/AsyrafHussin/agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for php-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/skills/asyrafhussin/agent-skills/php-best-practices/github.svg)](https://agentmods.dev/skills/asyrafhussin/agent-skills/php-best-practices)
Your own site
<a href="https://agentmods.dev/skills/asyrafhussin/agent-skills/php-best-practices"><img src="https://agentmods.dev/badge/skills/asyrafhussin/agent-skills/php-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for php-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/skills/asyrafhussin/agent-skills/php-best-practices"><img src="https://agentmods.dev/badge/skills/asyrafhussin/agent-skills/php-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,212 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 18 Mar 2026
  • Snyk pass 8 Mar 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00064 $0.02212
Opus 5 $0.00032 $0.01106
Sonnet 5 $0.00013 $0.00442
Haiku 4.5 $0.00006 $0.00221

Measured 9d ago against content hash ed70a7d31a2e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

php-best-practices 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 9d 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-best-practices/SKILL.md · 247 lines

How it starts

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

PHP Best Practices

Modern PHP 8.x patterns, PSR standards, type system best practices, and SOLID principles. Contains 51 rules for writing clean, maintainable PHP code.

Step 1: Detect PHP Version

Always check the project's PHP version before giving any advice. Features vary significantly across 8.0 - 8.5. Never suggest syntax that doesn't exist in the project's version.

Check composer.json for the required PHP version:

{ "require": { "php": "^8.1" } }   // -> 8.1 rules and below
{ "require": { "php": "^8.3" } }   // -> 8.3 rules and below
{ "require": { "php": ">=8.4" } }  // -> 8.4 rules and below

Also check the runtime version:

php -v   # e.g. PHP 8.3.12

Feature Availability by Version

Feature Version Rule Prefix
Union types, match, nullsafe, named args, constructor promotion, attributes 8.0+ type-, modern-
Enums, readonly properties, intersection types, first-class callables, never, fibers 8.1+ modern-
Readonly classes, DNF types, true/false/null standalone types 8.2+ modern-
Typed class constants, #[\Override], json_validate() 8.3+ modern-
Property hooks, asymmetric visibility, #[\Deprecated], new without parens 8.4+ modern-
Pipe operator ` >` 8.5+

Only suggest features available in the detected version. If the user asks about upgrading or newer features, mention what becomes available at each version.

When to Apply

Reference these guidelines when:

  • Writing or reviewing PHP code
  • Implementing classes and interfaces
  • Using PHP 8.x modern features
  • Ensuring type safety
  • Following PSR standards
  • Applying design patterns

Rule Categories by Priority

Priority Category Impact Prefix Rules
1 Type System CRITICAL type- 9
2 Modern PHP Features CRITICAL modern- 16
3 PSR Standards HIGH psr- 6
4 SOLID Principles HIGH solid- 5
5 Error Handling HIGH error- 5
6 Performance MEDIUM perf- 5
7 Security CRITICAL sec- 5

Read the full file on GitHub · 247 lines

Files

What ships with it

56 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 9d ago First seen · 247 lines · 64 tokens per session scan A ed70a7d31a2e

Subscribe to this mod's changes

php-best-practices is a skill published in the GitHub repository AsyrafHussin/agent-skills (74 stars, last pushed 12d ago), licensed MIT. It adds 64 tokens to every session and 2,212 once invoked, about $0.0003 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.

Related

Other skills, from other repositories

laravel-audit-architecture

Audit a Laravel application's architecture: boundaries, responsibility, coupling, duplication, and maintainability. Use when auditing architecture.

MrPunyapal/laravel-auditor · 30 tokens

laravel-audit-conventions

Audit a Laravel application for framework conventions: anti-patterns, version-appropriate APIs, and misuse of framework features. Use when auditing Laravel conventions.

MrPunyapal/laravel-auditor · 36 tokens

ring:adopting-lib-commons-huma-wrapper

Adopting the lib-commons/v5 shared Huma (OAS 3.1) OpenAPI wrapper + RFC 9457 problem model (commons/net/http/{openapi,problem}) in a Lerian Go service: wire openapi.New/ServeSpec + problem.Install (central >=500 scrub) on BOTH runtime and spec-gen paths, the per-rail problem.MapError flex seam, and rename-only spec…

LerianStudio/ring · 142 tokens

ring:applying-licenses

Applying or switching a repository's license (Apache 2.0, Elastic License v2, or Proprietary): rewrites the LICENSE file, updates Go/TS source headers, sets SPDX identifiers, and validates consistency after user confirmation. Use when asked to set, apply, or switch a license, or when scaffolding a service with no…

LerianStudio/ring · 94 tokens

ring:auditing-dependency-security

Auditing a dependency for supply-chain risk before install (pip/npm/go/cargo): checks typosquatting, maintainer/age risk, vulnerability DBs (OSV, GHSA, Socket), and lockfile hash pinning, then emits a risk score and approve/conditional/escalate/block decision. Use when adding or updating a dependency, reviewing a…

LerianStudio/ring · 102 tokens

laravel-auditor-development

Integrate and apply the Laravel Auditor package in Laravel applications: installation, setup, the MCP tools, and the audit workflow. Use when setting up Laravel Auditor or wiring it into a Laravel app.

MrPunyapal/laravel-auditor · 46 tokens