php-best-practices

Automate PHP 8.2+ modernization and PSR-12 compliance via Rector.

20|5|Updated Feb 27, 2026
One-click install
npx skills add https://github.com/nasrulhazim/agent-skills --skill php-best-practices-nasrulhazim
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: php-best-practices
Source: https://github.com/nasrulhazim/agent-skills/tree/main/skills/php-best-practices
Command: npx skills add https://github.com/nasrulhazim/agent-skills --skill php-best-practices-nasrulhazim

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides a structured approach to modernizing PHP codebases, enforcing quality standards, and guiding automated upgrades to PHP 8.2+ through Rector-driven tooling.

Core Features & Use Cases

  • Rector-driven upgrades: automate syntax and feature adoption from legacy PHP to PHP 8.2+.
  • Code quality & standards: enforce PSR-12, strict types, and better type declarations.
  • Refactoring guidance: detect smells and propose safe, incremental refactors with examples.
  • Use Case: teams maintaining Laravel apps can gradually modernize controllers, services, and models with minimal risk.

Quick Start

Run the Rector-based modernization pass over your PHP codebase to upgrade legacy code to PHP 8.2+ standards.

Frequently Asked Questions about php-best-practices

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

FAQPage Schema
How do I modernize legacy PHP code to PHP 8.2?

Enforce PSR-12 in a PHP codebase by applying automated Rector-driven modernization passes that standardize formatting, add strict types, and upgrade controllers and models to PHP 8.2+ standards.

What is the best way to add strict type declarations to an existing PHP project?

Refactor PHP code safely by using a conservative to aggressive adoption workflow that detects code smells and proposes incremental, automated refactors via Rector to minimize risk during upgrades.

Does Rector work with Laravel apps for automated PHP upgrades?

Static analysis detects code smells and validates type declarations during PHP refactoring, complementing Rector-driven upgrades by identifying areas requiring strict typing and quality enforcement.

How do I upgrade PHP codebases with minimal risk of breaking changes?

To modernize PHP with best-practice enforcement, run a Rector-based upgrade pass over your codebase to automatically apply strict types, PSR-12 compliance, and PHP 8.2+ syntax adoption.