php-laravel
Use when the user asks about Laravel, an Eloquent model with relationships, Form Requests, Laravel queues and jobs, API Resources, eager loading or…
от j4flmao★ 47 звёзд на GitHub
Установить php-laravel в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Laravel
Purpose
Build Laravel applications with clean MVC structure, service layer separation, Eloquent ORM best practices, form request validation, queue jobs, and comprehensive testing.
Agent Protocol
Trigger
User request includes: Laravel structure, Laravel app, Eloquent, Laravel service, Laravel validation, Laravel queue, Laravel testing, Laravel job, Laravel seeder.
Input Context
- Laravel version (10.x, 11.x)
- PHP version (8.1+)
- Database (MySQL, PostgreSQL, SQLite)
- Features (Auth, Queues, Broadcasting, Notifications, Cashier)
Output Artifact
Controller structure, service class, Eloquent model, form request, job class, seeder, test.
Response Format
Produce artifact directly. No preamble, no postamble, no explanations.
Completion Criteria
- Controller delegates to service layer
- Eloquent model with scopes, relations, casts
- Form request class with validation rules
- Service class with business logic
- Queue job with typed properties
- Feature/unit tests for critical paths
Max Response Length
4096 tokens
Architecture Decision Trees
Service Layer vs Repository vs Active Record
| Criterion | Service Layer | Repository | Active Record (Vanilla) |
|---|---|---|---|
| Business logic location | Service class | Repository class | Model methods |
| Query abstraction | Service delegates to model | Repository encapsulates | Direct in controllers |
| Testability | Easy (mock service) | Moderate (mock repo) | Hard (Eloquent facade) |
| Complexity | Moderate | High (extra layer) | Low |
| Laravel fit | Natural (dedicated directories) | Possible but uncommon | Default pattern |
Decision: Business logic outside controllers → Service Layer (most common in production Laravel apps). Need query abstraction → Repository. Simple CRUD → Active Record in controllers is acceptable.
Form Request vs Controller Validation
| Criterion | Form Request | Controller validate() | Manual validation |
|---|---|---|---|
| Reusability | Across controllers/actions | Per method | Per method |
| Authorization | Built-in authorize() | Manual in controller | Manual |
| Naming | StoreUserRequest |
Inline array | Inline array |
| Logic complexity | Custom rules, after hooks | Simple rules | Simple rules |
Decision: Reusable validation → Form Request. Simple one-off → Controller validate(). Complex custom logic → Form Request with custom rules.
Workflow
Step 1: Directory Structure
app/
Http/
Controllers/
Api/
V1/
UserController.php
OrderController.php
Requests/
StoreUserRequest.php
UpdateUserRequest.php
Resources/
UserResource.php
Models/
User.php
Order.php
Services/
UserService.php
OrderService.php
Jobs/
ProcessOrderJob.php
Exceptions/
ConflictException.php
database/
migrations/
xxxx_create_users_table.php
factories/
UserFactory.php
seeders/
UserSeeder.php
routes/
api.php
tests/
Feature/
UserTest.php
Unit/
UserServiceTest.php
Step 2: Eloquent Model
<?php
// app/Models/User.php
namespace App\Models;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, HasUuids, Notifiable;
protected $fillable = [
'name', 'email', 'password', 'role', 'is_active',
];
protected $hidden = ['password', 'remember_token'];
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'is_active' => 'boolean',
'created_at' => 'datetime:Y-m-d\TH:i:s\Z',
];
}
// Scopes
public function scopeActive($query)
{
return $query->where('is_active', true);
}
public function scopeByRole($query, string $role)
{
return $query->where('role', $role);
}
// Relations
public function posts(): HasMany
{
return $this->hasMany(Post::class);
}
// Accessors
public function getInitialsAttribute(): string
{
$parts = explode(' ', $this->name);
return collect($parts)->map(fn($p) => strtoupper($p[0]))->implode('');
}
// Events
protected static function booted(): void
{
static::created(function ($user) {
event(new UserCreated($user));
});
}
}
Step 3: Form Request Validation
<?php
// app/Http/Requests/StoreUserRequest.php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreUserRequest extends FormRequest
{
public function authorize():
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/artisan-commands.md
- references/eloquent-orm.md
- references/laravel-middleware-validation.md
- references/laravel-queues.md
- references/laravel-service-layer.md
- references/laravel-testing.md
FAQ
Что делает скилл php-laravel?
Use when the user asks about Laravel, an Eloquent model with relationships, Form Requests, Laravel queues and jobs, API Resources, eager loading or Pest/PHPUnit tests. Produces Laravel 11+ code with thin controllers and services. Not for Symfony (use symfony-backend) or plain PHP (use php-pure).
Как установить скилл php-laravel?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл php-laravel запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…