一键导入
php
General PHP coding standards covering strict typing, formatting, control flow, and error handling. Applies to all PHP files in the application.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
General PHP coding standards covering strict typing, formatting, control flow, and error handling. Applies to all PHP files in the application.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Readonly data containers with typed factory methods (`fromArray`, `fromModel`, `fromCollection`, `fromRequest`) used to pass structured data between application layers — especially for external API responses, Eloquent models, and service boundaries. Use this skill whenever creating, reviewing, or refactoring DTOs, Data Transfer Objects, value objects for inter-layer communication, or mapping payloads from APIs, models, or collections into typed PHP objects. Also trigger when the user mentions spatie/laravel-data alternatives, data mapping, or payload normalization in a Laravel context.
Eloquent model conventions for mass assignment, casts, relationship naming, activity logging, and mandatory model tests (CRUD + relations).
Single-purpose business logic classes that encapsulate one well-defined business operation. Actions are the primary location for business logic in Laravel applications, invoked from controllers, commands, or jobs.
Albatros accounting API integration via Saloon. Use when working with app/Services/Albatros/, AlbatrosConnector, or Albatros DTOs.
Laravel Blade template conventions covering components, output escaping, security, structure, and formatting.
Artisan console command classes that serve as the CLI entry point for operations. Commands validate input and delegate all business logic to Actions or Services.
| name | php |
| description | General PHP coding standards covering strict typing, formatting, control flow, and error handling. Applies to all PHP files in the application. |
| compatible_agents | ["architect","implement","refactor","review"] |
app/, tests/, and supporting project PHP files).phpstan, controllers, requests, etc.).?Type) where neededelse, elseif, or nested if blocks — invert the condition and return earlyreadonly properties where possible; use mutable properties only when state must evolve across method callselse rule.// ✓ Early returns — guard clauses
public function process(Order $order): void
{
if (! $order->isPaid()) {
throw new UnpaidOrderException();
}
if (! $order->hasItems()) {
throw new EmptyOrderException();
}
// Happy-path logic here
}
// ✗ Nested if/else — never do this
public function process(Order $order): void
{
if ($order->isPaid()) {
if ($order->hasItems()) {
// deep logic
} else {
throw new EmptyOrderException();
}
} else {
throw new UnpaidOrderException();
}
}
// ✓ Fully typed class
class CreateInvoice
{
public function __construct(
private readonly GenerateInvoicePdf $generatePdf,
) {}
public function execute(Order $order): Invoice
{
// implementation
}
}
// ✗ Anti-pattern: swallowed exception
try {
$this->externalService->call($data);
} catch (Throwable $e) {
// no logging, no rethrow, no fallback
}
// ✓ Structured logging when catching
try {
$this->externalService->call($data);
} catch (ServiceException $e) {
Log::error('External service failed.', [
'message' => $e->getMessage(),
'data' => $data,
]);
throw $e;
}
// ✓ Retry transient failures, then catch once for context and rethrow
try {
return retry(3, fn () => $this->gateway->charge($payload), 200);
} catch (GatewayTimeoutException $e) {
Log::warning('Charge failed after retries.', ['order_id' => $orderId]);
throw $e;
}
// ✓ Foreign-language DTO terms are acceptable when mirroring external API fields
readonly class AdresseData
{
public function __construct(
public string $ID,
public ?string $Strasse,
public ?string $PLZ,
) {}
}
else or elseif — invert and return early insteadenv() directly in application code (only in config files)mixed access/calls without narrowing@phpstan-ignore* as last resort; each usage needs an inline reason.pint.json (if present) defines local Pint behaviorphpstan.neon defines local static-analysis scope and strictnessPHPStan/SKILL.md — static analysis complianceelse/elseif