Back to Rules
Web Development

Laravel Vue.js Full-Stack Best Practices: SOLID Principles, MVC Architecture & Eloquent Guide

Claude Directory November 29, 2025
0 copies 1 downloads

Master Laravel and Vue.js full-stack development with rewritten principles focusing on SOLID OOP, strict typing, Eloquent ORM, Pinia state management, and performance optimization for scalable web apps.

Rule Content
**Do:** Adopt SOLID principles in OOP for maintainable code, using dependency injection via Laravel's service container.
**Example:**
```php
// Good: Inject dependencies
class UserService {
    public function __construct(private UserRepository $repo) {}
}
```

**Don't:** Duplicate code; instead, iterate and modularize reusable logic.
**Example:**
```php
// Bad: Copy-paste validation
// Good: Extract to trait or service
trait Validatable {
    public function validateUser(array $data): bool { /* logic */ }
}
```

**Do:** Use descriptive names and follow Laravel's directory structure (e.g., app/Http/Controllers).
**Example:**
```php
// File: app/Http/Controllers/UserController.php
class UserController extends Controller { /* methods */ }
```

**Don't:** Ignore strict typing; always declare(strict_types=1) and leverage PHP 8.2+ features like readonly properties.
**Example:**
```php
<?php
declare(strict_types=1);
class User {
    public function __construct(public readonly string $name) {}
}
```

**Do:** Implement PSR-12 standards, Eloquent ORM, migrations, and request validation with Form Requests.
**Example:**
```php
// Migration
public function up(): void {
    Schema::create('users', function (Blueprint $table) {
        $table->id()->index();
    });
}
// FormRequest
class StoreUserRequest extends FormRequest {
    public function rules(): array { return ['name' => 'required']; }
}
```

**Don't:** Handle errors manually; use Laravel's exception handling, logging, and try-catch for predictable issues.
**Example:**
```php
try {
    $user = User::findOrFail($id);
} catch (ModelNotFoundException $e) {
    Log::error('User not found', ['id' => $id]);
    throw new CustomUserException('User missing');
}
```

**Do:** Organize Vue.js with Vite, src/components folder, lazy-loaded routes via Vue Router, and modular Pinia stores.
**Example:**
```vue
<!-- src/components/UserList.vue -->
<script setup>
const store = useUserStore();
const users = store.users;
</script>
```

**Don't:** Skip form validation; integrate Vuelidate and style with TailwindCSS/PrimeVue.
**Example:**
```vue
<script setup>
import { useVuelidate } from '@vuelidate/core';
const rules = { name: required };
const v$ = useVuelidate(rules, state);
</script>
```

**Do:** Secure APIs with Laravel Passport, CSRF, caching, queues, and testing via PHPUnit/Dusk.
**Example:**
```php
Route::middleware('auth:api')->group(function () {
    Route::apiResource('users', UserController::class);
});
// Cache
Cache::remember('users', 3600, fn() => User::all());
```

**Don't:** Neglect scalability; use events/listeners, job queues, scheduling, and API versioning.
**Example:**
```php
// Event
Event::listen(UserCreated::class, SendWelcomeEmail::class);
// Schedule
$schedule->command('users:cleanup')->daily();

Comments

More Rules

View all
AI/ML

GLM-4.7 Optimized Config & System Prompt Designer

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.

C
Community
AI/ML

GLM-4.7 Open-Source Coding Expert: Optimized System Prompt

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.

C
Community
AI/ML

GLM-4.7 Optimized Coding Agent

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.

C
Community
DevOps

Agentic Dev Loop: Autonomous Jira-Driven Coding Agent with GitHub CI Self-Healing

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.

C
Claude Directory
AI/ML

Türk Hukuku Uzmanı AI Agent: Güvenilir Yasal Danışman System Prompt

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.

C
Community
Database

PostgreSQL Best Practices: Expert Subagent Guide

Expert subagent providing production-ready PostgreSQL guidance on schema design, query optimization, security, performance tuning, and administration with structured, actionable advice and official references.

C
Claude Directory