php-best-practices

Audit PHP 8+ codebases for type-safety, PSR compliance, and SOLID design.

62|9|Updated Jan 16, 2026
One-click install
npx skills add https://github.com/AsyrafHussin/agent-skills --skill php-best-practices-asyrafhussin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: php-best-practices
Source: https://github.com/AsyrafHussin/agent-skills/tree/main/skills/php-best-practices
Command: npx skills add https://github.com/AsyrafHussin/agent-skills --skill php-best-practices-asyrafhussin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PHP projects often suffer from inconsistent patterns, weak typing, and non-adherence to standards, leading to fragile codebases and higher maintenance costs.

Core Features & Use Cases

  • Enforces strict types, return and parameter type declarations, and modern PHP features (constructor promotion, enums, readonly properties).
  • Promotes PSR-4 autoloading, PSR-12 coding style, and SOLID principles to improve maintainability, scalability, and collaboration.
  • Useful during code reviews, refactoring, and building robust, secure PHP applications across teams.

Quick Start

Immediately audit a PHP codebase for strict types, PSR compliance, and SOLID practices to elevate code quality.

Frequently Asked Questions about php-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit a PHP codebase for PSR compliance and SOLID design?

You can enforce strict_types, return types, and PSR-12 coding style by applying static analysis during code reviews and refactoring. This ensures parameter type declarations and modern PHP 8+ features like constructor promotion and readonly properties are consistently used.

What is the best way to enforce type-safety in PHP 8+ projects?

The best way to enforce type-safety in PHP 8+ projects is by applying strict_types declarations, union types, and return type signatures across the codebase. Automated static analysis checks these modern PHP features to prevent fragile code and reduce maintenance costs.

Why does my PHP codebase suffer from inconsistent patterns and weak typing?

PHP codebases suffer from inconsistent patterns and weak typing due to non-adherence to standards and missing strict type declarations. Auditing against PSR-4, PSR-12, and SOLID principles identifies these structural weaknesses to resolve fragility and high maintenance costs.

When do I need to apply strict_types and PSR standards in PHP?

You need to apply strict_types and PSR standards in PHP during code reviews, refactoring, and building robust applications across teams. Enforcing these standards ensures type-safety, secure coding patterns, and improved collaboration in PHP 8+ projects.