AGENT SKILL

php-architect

Architect-level PHP guidance — framework and layering choices, request lifecycle and shared-nothing deployment, autoloading and dependency injection, database and session boundaries, and the operational reality of PHP-FPM. Use when designing or reviewing a PHP backend.

License 许可
MIT
最近更新
2026-11-13
Stars
★ 0
Forks
0

01 前言 Front Matter

name
php-architect
license
MIT
metadata
{ "crusor-path": "website-architect/backend-development-architect/php-architect", "crusor-domain": "website-architect", "crusor-origin": "original", "crusor-sources": "php.net/manual; laravel.com/docs; symfony.com/doc/current; php-fig.org/psr", "crusor-triggers": "php, laravel, symfony, php-fpm, composer, psr, eloquent, blade", "crusor-verified-on": "2026-10-30" }
description
Architect-level PHP guidance — framework and layering choices, request lifecycle and shared-nothing deployment, autoloading and dependency injection, database and session boundaries, and the operational reality of PHP-FPM. Use when designing or reviewing a PHP backend.
compatibility
PHP 8.2+; Laravel / Symfony / plain PSR-15

03 SKILL.md 正文

PHP Architect

PHP's defining property is shared-nothing: each request starts clean. That is a strength — until someone reintroduces hidden global state.

When to use

  • Content platforms, e-commerce, internal apps with a PHP team.
  • Laravel/Symfony projects needing boundaries beyond "everything in controllers".
  • Migrating legacy PHP into a maintained structure.

When NOT to use

  • Long-running, stateful services (websockets, workers) — possible, but other runtimes fit better.

Decision 1 — Structure

public/index.php     front controller, nothing else
  src/Http/          controllers, requests/validation
    src/Domain/      entities, value objects, rules
      src/Application/ services, use-cases
        src/Infrastructure/ repositories, external clients
  • PSR-4 autoloading; one class per file; composer owns the autoloader.
  • Framework code stays in Http/Infrastructure; the domain has no framework imports.
  • Dependency injection via the container, constructor injection only; no service locators inside domain code.

Decision 2 — Request lifecycle

Concern Rule
validation at the edge (FormRequest/Validator), typed DTO inward
auth middleware/guard; authorization policies per resource
sessions server-side store, regenerated on login
output escaped by default (Blade/Twig); raw output requires a sanitiser
errors one handler → JSON envelope, never a stack trace
  • Shared-nothing means no static caches surviving a request — use the cache backend, not a static property.
  • Config from environment, validated at boot; env() outside config files is a bug.

Decision 3 — Data access

  • Eloquent/Doctrine are fine in Infrastructure; the domain sees repository interfaces.
  • Eager-load relations (with()), otherwise N+1 is guaranteed on list pages.
  • Migrations versioned and reversible; no manual DDL in production.
  • Transactions in services; no email/HTTP calls inside a transaction.

Decision 4 — Runtime and operations

  • PHP-FPM pool sized to CPU and DB connections; pm.max_children is the real concurrency limit.
  • Opcache enabled in production; preload only after measuring.
  • Queues (Horizon/Worker) for anything slow; jobs idempotent.
  • Deploy: build artefacts, composer install --no-dev --optimize-autoloader, cache warm-up, then release — no composer update on the production box.

Failure modes at scale

  • Business logic in Blade templates.
  • env() called in application code (breaks once config is cached).
  • N+1 on the product listing page.
  • Unbounded FPM children exhausting DB connections.
  • A deploy that runs migrations and code changes at the same instant, with no rollback path.

Verification receipts

  1. Query count on the busiest list page (eager loading proven).
  2. Config cache + opcache verified in production.
  3. FPM children vs DB max_connections documented.
  4. Queue job idempotency test.
  5. Static analysis (PHPStan/Psalm) and composer audit clean in CI.

04 同仓库更多 Skills

SriAkhilSJ
SriAkhilSJ/PulseAIRepo

interaction-patterns-architect

Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

design-system-ops-architect

Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

design-handoff-architect

Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

content-microcopy-architect

Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

ui-ux-implementation-architect

Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

test-strategy-architect

Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.

★ 0