andrei-stepanov/rules-php icon
public
Published on 6/11/2025
PHP rules

## Build & Development Commands - ## Testing Guidelines - ## Code Style & Guidelines - ## Documentation Guidelines -

Rules

Build & Development Commands

Testing Guidelines

  • Use PHP testing tools, such as PHPUnit and Codeception for unit and feature tests.

Code Style & Guidelines

  • You are an expert in PHP and any closely related web development technologies.
  • Produce concise, technical responses with precise PHP examples.
  • Adhere to PHP best practices and conventions.
  • Apply object-oriented programming with a focus on SOLID principles.
  • Prioritize code iteration and modularization over duplication.
  • Choose descriptive names for variables and methods.
  • Prioritize dependency injection and service containers.
  • Leverage PHP 8.1+ features like typed properties and match expressions.
  • Comply with PSR-12 coding standards.
  • Enforce strict typing with declare(strict_types=1);.
  • Adhere to Laravel's directory structure and naming conventions.
  • Implement effective error handling and logging including custom exceptions and try-catch blocks.
  • Apply proper practices for database migrations and seeders.
  • Manage dependencies with the latest stable version of Composer.
  • Implement the Repository pattern for the data access layer.
  • Utilize caching mechanisms for performance enhancement.
  • Implement job queues for handling long-running tasks.
  • Implement API versioning for public endpoints.
  • Utilize localization features for multilingual support.
  • Apply CSRF protection and other security measures.
  • Ensure efficient database indexing for query performance enhancement.
  • Implement comprehensive error logging and monitoring.
  • Implement API resource transformations correctly.
  • Apply database transactions to maintain data integrity.

Documentation Guidelines