본문으로 건너뛰기
cccskills
무료GitHub에 공개

php

Modern PHP 8.5 practices: type system, OOP, security, architecture, async, testing, tooling. Use when writing or reviewing PHP code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md5.8 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

PHP

Runtime and versioning

  • Run PHP 8.4 (active support) or 8.5 (latest stable). Never run EOL versions — no security patches
  • declare(strict_types=1) at top of every file
  • OPcache enabled in production. opcache.preload for warm startup on 8.0+
  • JIT enabled for CPU-bound workloads: opcache.jit=tracing, opcache.jit_buffer_size=128M. Not beneficial for typical I/O-bound web apps — benchmark before enabling

Type system

  • Type-hint all parameters, return types, and properties. No mixed — use union types (int|string) or generics via PHPDoc
  • never return type for functions that always throw or exit
  • readonly properties for value objects and DTOs (8.1+). readonly classes (8.2+) for fully immutable objects
  • Asymmetric visibility (8.4+): public private(set) for properties readable everywhere but writable only within class
  • Property hooks (8.4+): get/set hooks on properties — eliminates getter/setter boilerplate. Incompatible with readonly
  • Intersection types (8.1+): Countable&Iterator. DNF types (8.2+): (A&B)|null
  • Typed class constants (8.3+): const string VERSION = '1.0'
  • #[Override] attribute (8.3+) on overriding methods — compiler-checked safety net
  • Enums over constants for closed value sets (8.1+). Backed enums (string/int) for serialisation
  • Named arguments for multi-param functions with non-obvious order. Not for all calls
  • match over switch — exhaustive, no fall-through, returns value
  • First-class callable syntax (8.1+): strlen(...) over Closure::fromCallable('strlen')

Modern syntax (8.4–8.5)

  • new without parentheses for chaining (8.4+): new Collection()->filter()->map()
  • Pipe operator (8.5+): $result = $value |> trim(...) |> strtolower(...) |> htmlspecialchars(...). Prefer over nested calls
  • clone with (8.5+): $new = clone $obj with {name: 'updated'}. Preferred over manual clone + property set
  • Static property asymmetric visibility (8.5+): same syntax as instance properties
  • Lazy objects (8.4+): built-in lazy initialisation via ReflectionClass::newLazyProxy(). Use for expensive dependencies in DI containers
  • Driver-specific PDO classes (8.4+): Pdo\Mysql, Pdo\Pgsql, Pdo\Sqlite — type-safe, IDE-friendly alternatives to generic PDO

Error handling

  • Throw exceptions, never return error codes or false
  • Catch specific exception types. Never catch \Throwable at the business layer
  • Custom exception classes for domain errors callers need to handle
  • Log full exception context. Never swallow silently
  • Fatal error backtraces (8.5+): enable via zend.exception_ignore_args=0 — error_get_last() now includes trace key

Security

  • Never trust user input. Validate and sanitise at every entry point
  • Parameterised queries only — PDO driver classes (8.4+) or PDO with prepared statements. Never string interpolation in SQL
  • password_hash() / password_verify() with PASSWORD_BCRYPT or PASSWORD_ARGON2ID. Never MD5/SHA1
  • Escape all output for context: HTML → htmlspecialchars(), shell → escapeshellarg() or proc_open() with arg array (never shell string)
  • Never eval(), exec(), system(), shell_exec() with user-controlled input
  • Secrets in env or secret manager. Never in code or committed config
  • Session cookies: HttpOnly, Secure, SameSite=Strict. Partitioned cookie support (8.5+) via setcookie() partitioned option
  • CSP, CSRF protection, rate limiting on all forms and auth endpoints
  • composer audit in CI. Fail on known vulnerabilities
  • Keep dependencies updated. composer outdated as part of regular maintenance

Architecture

  • PSR-12 coding standard. Enforce with PHP-CS-Fixer or Pint in CI
  • PSR-4 autoloading. No manual require/include in application code
  • Depend on abstractions (interfaces), not concretions. Inject dependencies
  • Service classes do one thing. No business logic in controllers or views
  • Value objects for domain concepts (Money, Email, UserId) — primitives leak
  • Repositories only when data source swapping is a real requirement

Async and concurrency

  • Fibers (8.1+): cooperative multitasking within a single thread. Foundation for async runtimes
  • ReactPHP or AMPHP for event-loop-based async I/O. Swoole/OpenSwoole for coroutine-based high-concurrency servers
  • Shared-nothing model is default PHP. Fibers do not add multi-threading — I/O concurrency only
  • Avoid blocking calls (file_get_contents, sleep) inside fiber/event-loop context

Composer and dependencies

  • Pin major versions in composer.json. composer.lock committed to git
  • composer audit and composer outdated in CI
  • composer install --no-dev --optimize-autoloader in production. Never --no-scripts unless you understand what you're skipping
  • Separate require from require-dev. Testing and analysis tools in dev only
  • Evaluate package maintenance health before adopting. Abandoned packages are a security risk

Testing

  • Pest preferred for new projects. PHPUnit for existing codebases — don't mix
  • Test behaviour, not implementation. No exposing private methods for testing
  • Mock external services (HTTP, queues, storage). Never mock your own domain classes
  • PHPStan at level 8+ or Psalm with strict mode. Run in CI, fail on errors
  • Mutation testing with Infection for critical business logic
  • phpbench for performance-sensitive code. Benchmark before and after optimisation

Performance

  • Profile first: Xdebug (development), Never optimise blind
  • Generators for large dataset iteration. Never load unbounded results into memory
  • Avoid N+1 queries. Eager-load relationships
  • SplFixedArray for large homogeneous datasets. Lower memory overhead than plain arrays
  • Fibers/async for I/O concurrency. JIT for CPU-bound computation

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

aws

무료

AWS best practices: IAM, secrets, networking, security, compute, IaC, ops. Use when building, reviewing, or modifying AWS resources.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

docker

무료

Docker best practices: image security, build efficiency, runtime hardening, Compose, local tooling (Colima, OrbStack). Use when writing or reviewing Dockerfiles and Compose files.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

gcp

무료

GCP best practices: IAM, secrets, networking, security, compute, IaC, ops. Use when building, reviewing, or modifying GCP resources.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

go

무료

Idiomatic Go 1.25 practices: errors, interfaces, concurrency, generics, testing, security, tooling. Use when writing or reviewing Go code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

java

무료

Modern Java practices: design, errors, concurrency, security, testing, tooling. Targets Java 21 LTS baseline; Java 25 LTS features called out explicitly. Use when writing or reviewing Java code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid overcomplication, make surgical changes, surface assumptions, and define verifiable success criteria.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SumonMSelim/agentguard542026년 10월 12일 업데이트

SumonMSelim의 스킬 모두 보기

이 스킬의 문제 신고