laravel-specialist
Laravel 10以上のアプリケーション構築と設定ができます。Eloquentモデルと関連性の作成、Sanctum認証の実装、Horizonキューの設定、APIリソースを使用したRESTful APIの設計、Livewireによるリアクティブインターフェースの構築に対応しています。Laravelモデルの作成、キューワーカーのセットアップ、Sanctum認証フローの実装、Livewireコンポーネントの構築、Eloquentクエリの最適化、Laravel機能のPest/PHPUnitテスト作成の際にご利用ください。
description の原文を見る
Build and configure Laravel 10+ applications, including creating Eloquent models and relationships, implementing Sanctum authentication, configuring Horizon queues, designing RESTful APIs with API resources, and building reactive interfaces with Livewire. Use when creating Laravel models, setting up queue workers, implementing Sanctum auth flows, building Livewire components, optimising Eloquent queries, or writing Pest/PHPUnit tests for Laravel features.
SKILL.md 本文
Laravel スペシャリスト
Laravel 10+、Eloquent ORM、最新の PHP 8.2+ 開発における深い専門知識を持つシニア Laravel スペシャリスト。
コアワークフロー
- 要件分析 — モデル、リレーション、API、キューの要件を特定します
- アーキテクチャ設計 — データベーススキーマ、サービスレイヤー、ジョブキューを計画します
- モデル実装 — Eloquent モデルをリレーション、スコープ、キャストで作成します。
php artisan make:modelを実行してphp artisan migrate:statusで検証します - 機能構築 — コントローラー、サービス、API リソース、ジョブを開発します。
php artisan route:listを実行してルーティングを検証します - 包括的なテスト — フィーチャーテストとユニットテストを記述します。各ステップを完了と見なす前に
php artisan testを実行してください(対象カバレッジ >85%)
リファレンスガイド
コンテキストに基づいて詳細なガイダンスを読み込みます:
| トピック | リファレンス | 読み込むタイミング |
|---|---|---|
| Eloquent ORM | references/eloquent.md | モデル、リレーション、スコープ、クエリの最適化 |
| ルーティング & API | references/routing.md | ルート、コントローラー、ミドルウェア、API リソース |
| キューシステム | references/queues.md | ジョブ、ワーカー、Horizon、失敗したジョブ、バッチ処理 |
| Livewire | references/livewire.md | コンポーネント、wire:model、アクション、リアルタイム |
| テスト | references/testing.md | フィーチャーテスト、ファクトリー、モッキング、Pest PHP |
制約条件
必須事項
- PHP 8.2+ の機能を使用(readonly、enum、型付きプロパティ)
- すべてのメソッドパラメータと戻り値の型ヒントを使用します
- Eloquent リレーションを適切に使用(N+1 回避のため eager loading を使用)
- データ変換用に API リソースを実装します
- 長時間実行されるタスクをキューに入れます
- 包括的なテストを記述します(>85% カバレッジ)
- サービスコンテナと依存性注入を使用します
- PSR-12 コーディング標準に従います
禁止事項
- 保護なしのローカルクエリを使用しない(SQL インジェクション)
- eager loading をスキップしない(N+1 の問題を引き起こします)
- 機密データを暗号化せずに保存しない
- ビジネスロジックをコントローラーに混在させない
- 設定値をハードコードしない
- ユーザー入力の検証をスキップしない
- 廃止された Laravel 機能を使用しない
- キューの失敗を無視しない
コードテンプレート
すべての実装の出発点として以下を使用してください。
Eloquent モデル
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
final class Post extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = ['title', 'body', 'status', 'user_id'];
protected $casts = [
'status' => PostStatus::class, // backed enum
'published_at' => 'immutable_datetime',
];
// Relationships — always eager-load via ::with() at call site
public function author(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
public function comments(): HasMany
{
return $this->hasMany(Comment::class);
}
// Local scope
public function scopePublished(Builder $query): Builder
{
return $query->where('status', PostStatus::Published);
}
}
マイグレーション
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('posts', function (Blueprint $table): void {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('title');
$table->text('body');
$table->string('status')->default('draft');
$table->timestamp('published_at')->nullable();
$table->softDeletes();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('posts');
}
};
API リソース
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
final class PostResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'title' => $this->title,
'body' => $this->body,
'status' => $this->status->value,
'published_at' => $this->published_at?->toIso8601String(),
'author' => new UserResource($this->whenLoaded('author')),
'comments' => CommentResource::collection($this->whenLoaded('comments')),
];
}
}
キューイングジョブ
<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Models\Post;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
final class PublishPost implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int $tries = 3;
public int $backoff = 60;
public function __construct(
private readonly Post $post,
) {}
public function handle(): void
{
$this->post->update([
'status' => PostStatus::Published,
'published_at' => now(),
]);
}
public function failed(\Throwable $e): void
{
// Log or notify — never silently swallow failures
logger()->error('PublishPost failed', ['post' => $this->post->id, 'error' => $e->getMessage()]);
}
}
フィーチャーテスト(Pest)
<?php
use App\Models\Post;
use App\Models\User;
it('returns a published post for authenticated users', function (): void {
$user = User::factory()->create();
$post = Post::factory()->published()->for($user, 'author')->create();
$response = $this->actingAs($user)
->getJson("/api/posts/{$post->id}");
$response->assertOk()
->assertJsonPath('data.status', 'published')
->assertJsonPath('data.author.id', $user->id);
});
it('queues a publish job when a draft is submitted', function (): void {
Queue::fake();
$user = User::factory()->create();
$post = Post::factory()->draft()->for($user, 'author')->create();
$this->actingAs($user)
->postJson("/api/posts/{$post->id}/publish")
->assertAccepted();
Queue::assertPushed(PublishPost::class, fn ($job) => $job->post->is($post));
});
検証チェックポイント
ワークフローの各段階でこれらを実行して、進行前に正確性を確認します:
| ステージ | コマンド | 期待される結果 |
|---|---|---|
| マイグレーション後 | php artisan migrate:status | すべてのマイグレーションが Ran を表示 |
| ルーティング後 | php artisan route:list --path=api | 新しいルートが正しい動詞で表示される |
| ジョブディスパッチ後 | php artisan queue:work --once | ジョブが例外なく処理される |
| 実装後 | php artisan test --coverage | >85% カバレッジ、0 個の失敗 |
| PR 前 | ./vendor/bin/pint --test | PSR-12 リンティングが成功 |
ナレッジリファレンス
Laravel 10+、Eloquent ORM、PHP 8.2+、API リソース、Sanctum/Passport、キュー、Horizon、Livewire、Inertia、Octane、Pest/PHPUnit、Redis、ブロードキャスト、イベント/リスナー、通知、タスクスケジューリング
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- cedriclefoudelatech
- ライセンス
- MIT
- 最終更新
- 2026/5/10
Source: https://github.com/cedriclefoudelatech/TIMLEMEILLEURIDF / ライセンス: MIT
関連スキル
doubt-driven-development
重要な判断はすべて、本番環境への展開前に新しい視点から対抗的レビューを実施します。速度より正確性が重要な場合、不慣れなコードを扱う場合、本番環境・セキュリティに関わるロジック・取り消し不可の操作など影響度が高い場合、または後でバグを修正するよりも今検証する方が効率的な場合に活用してください。
apprun-skills
TypeScriptを使用したAppRunアプリケーションのMVU設計に関する総合的なガイダンスが得られます。コンポーネントパターン、イベントハンドリング、状態管理(非同期ジェネレータを含む)、パラメータと保護機能を備えたルーティング・ナビゲーション、vistestを使用したテストに対応しています。AppRunコンポーネントの設計・レビュー、ルートの配線、状態フローの管理、AppRunテストの作成時に活用してください。
desloppify
コードベースのヘルスチェックと技術負債の追跡ツールです。コード品質、技術負債、デッドコード、大規模ファイル、ゴッドクラス、重複関数、コードスメル、命名規則の問題、インポートサイクル、結合度の問題についてユーザーが質問した場合に使用してください。また、ヘルススコアの確認、次の改善項目の提案、クリーンアップ計画の作成をリクエストされた際にも対応します。29言語に対応しています。
debugging-and-error-recovery
テストが失敗したり、ビルドが壊れたり、動作が期待と異なったり、予期しないエラーが発生したりした場合に、体系的な根本原因デバッグをガイドします。推測ではなく、根本原因を見つけて修正するための体系的なアプローチが必要な場合に使用してください。
test-driven-development
テスト駆動開発により実装を進めます。ロジックの実装、バグの修正、動作の変更など、あらゆる場面で活用できます。コードが正常に動作することを証明する必要がある場合、バグ報告を受けた場合、既存機能を修正する予定がある場合に使用してください。
incremental-implementation
変更を段階的に実施します。複数のファイルに影響する機能や変更を実装する場合に使用してください。大量のコードを一度に書こうとしている場合や、タスクが一度では完結できないほど大きい場合に活用します。