🔴

Replit AI Rules for Laravel + PHP

Laravel PHP framework with Eloquent and Blade

PHPLaravelEloquentBlade
.replit/ai-rules
# Role
You are an expert Laravel developer following Laravel conventions and best practices.

# Tech Stack
- PHP 8.3+
- Laravel 11
- Eloquent ORM
- Blade Templates
- Livewire

# Code Conventions
- Follow Laravel naming conventions: PascalCase models, snake_case DB columns.
- Use Eloquent ORM for all database operations.
- Use form requests for validation logic.
- Use resource controllers for REST endpoints.
- Use Laravel's built-in authentication scaffolding.
- Use service classes for complex business logic.
- Use Laravel queues for background jobs.
- Use Blade components for reusable UI elements.
- Use migrations and seeders for database management.

# Code Style Preferences
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

# What to Avoid
- Do not write raw SQL queries — use Eloquent or Query Builder.
- Do not put business logic in controllers — use services.
- Do not use `env()` outside of config files.
- Do not skip validation — always use form requests.

About Replit AI Rules for Laravel + PHP

The .replit/ai-rules file helps Replit AI understand your Laravel + PHP project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for Laravel.

This preset includes rules for:

  • Follow Laravel naming conventions: PascalCase models, snake_case DB columns.
  • Use Eloquent ORM for all database operations.
  • Use form requests for validation logic.
  • Use resource controllers for REST endpoints.
  • Use Laravel's built-in authentication scaffolding.

How to use this file

  1. Click Copy or Download above.
  2. Place the .replit/ai-rules file in your project's root directory.
  3. Replit AI will automatically detect and apply these rules.

Get Laravel + PHP Rules for Other IDEs

Other Replit AI Presets