PHP Cursor Rules
Cursor rules for PHP: modern PHP 8 patterns, strict types, type declarations, and secure PHP development.
- Add declare(strict_types=1) at the top of every PHP file - Use union types, intersection types, and enums (PHP 8.1+) for expressiveness - Use constructor property promotion to reduce boilerplate in classes - Use named arguments for clarity when calling functions with many parameters - Never use extract() or eval(); avoid variable variables - Use the null coalescing operator (??) and nullsafe operator (?->) consistently - Use Composer for all dependency management; never manual file includes - Follow PSR-12 coding standard; use PHP-CS-Fixer in CI
How to use with Cursor
Create a `.cursorrules` file in your project root and paste these rules. Cursor reads this automatically on every AI interaction.
Related Rules
Python Cursor Rules
Best Cursor AI coding rules for Python development. Enforce type hints, PEP 8, Pythonic patterns, and modern Python best practices in your .cursorrules file.
TypeScript Cursor Rules
Cursor rules for TypeScript: enforce strict mode, eliminate any types, and write type-safe code with these .cursorrules configurations.
React Cursor Rules
Cursor rules for React: component patterns, hooks best practices, performance optimization, and clean state management conventions.
Next.js Cursor Rules
Cursor rules for Next.js App Router: server components, data fetching, routing, and deployment best practices.