Loading...
Loading...
Unlock expert Laravel PHP coding standards with rewritten rules focusing on SOLID principles, Eloquent ORM, MVC architecture, and performance optimizations for scalable web apps.
### Context
These guidelines are tailored for Laravel PHP developers using AI-assisted tools like Cursor. They promote clean, maintainable code by adhering to Laravel conventions, modern PHP features, and best practices. Prioritize modularity, dependency injection, and built-in Laravel tools to build robust applications efficiently.
### Rules
- **Adopt Modern PHP Standards**: Leverage PHP 8.1+ capabilities such as typed properties and match statements. Enforce strict typing with `declare(strict_types=1);` and comply with PSR-12 formatting.
- **Embrace Laravel Structure**: Stick to Laravel's directory conventions (e.g., `app/Http/Controllers` in kebab-case). Use MVC patterns, Blade for views, and Eloquent for models with proper relationships.
- **Prioritize OOP and SOLID**: Write modular, iterable code avoiding duplication. Use descriptive names, dependency injection via service containers, and Repository patterns for data abstraction.
- **Handle Data and Security Robustly**: Prefer Eloquent ORM and query builder over raw SQL. Implement Form Requests for validation, middleware for filtering, custom exceptions, and Laravel's auth, CSRF, and authorization.
- **Optimize Performance and Reliability**: Apply caching, job queues, pagination, indexing, and transactions. Use events/listeners for decoupling, scheduling for tasks, and Mix/Vite for assets.
- **Testing and Maintenance**: Integrate PHPUnit/Dusk for tests, API versioning/resources, localization, and comprehensive logging/monitoring.
- **Routing and APIs**: Define endpoints with Laravel routing, transform responses via API resources, and version public APIs.
### Examples
**Strict Typing and Typed Properties**:
```php
declare(strict_types=1);
class UserController
{
public function __construct(private UserRepository $repository) {}
public function index(Request $request): LengthAwarePaginator
{
return $this->repository->getUsers($request->get('search'));
}
}
```
**Eloquent Relationship and Repository**:
```php
// app/Repositories/UserRepository.php
class UserRepository
{
public function getUsers(?string $search = null): LengthAwarePaginator
{
return User::search($search)
->with('posts')
->paginate(15);
}
}
// Model
class User extends Model
{
public function posts(): HasMany
{
return $this->hasMany(Post::class);
}
}
```
**Form Request Validation**:
```php
// app/Http/Requests/StoreUserRequest.php
class StoreUserRequest extends FormRequest
{
public function rules(): array
{
return ['email' => 'required|email|unique:users'];
}
}Expert system prompt for designing high-performance configurations tailored to GLM-4.7's strengths in coding, reasoning, tool use, and multilingual tasks, backed by benchmarks like SWE-bench and τ²-Bench.
Leverage GLM-4.7's top benchmarks in SWE-bench, LiveCodeBench, and more with this system prompt designed for generating clean, secure, open-source-ready code, stunning UIs, and agentic workflows.
This system prompt transforms an AI into GLM-4.7, a benchmark-leading coding agent excelling in agentic workflows, tool use, multilingual coding, and complex reasoning with verified best practices for production-ready open-source development.
Ralph, a persistent autonomous AI agent, implements Jira tickets through an endless loop until 100% test success, with GitHub PRs, Jules AI reviews, and CI self-healing for reliable development workflows.
Claude'u Türk hukuku alanında dünyanın en önde gelen uzmanı olarak yapılandıran, yapılandırılmış yanıtlar, zorunlu uyarılar ve etik sınırlarla donatılmış profesyonel AI agent promptu.
Expert subagent providing production-ready PostgreSQL guidance on schema design, query optimization, security, performance tuning, and administration with structured, actionable advice and official references.