Skip to content
Back to skills

Coding

ASecurity

Speed up modern PHP (8.4 and later): OPcache and JIT, worker-mode servers, N+1 fixes, static analysis, tests with Pest. Use when a PHP or Symfony service is slow, or when upgrading PHP versions and tooling.

  • 24 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added October 14, 2026
ai-agentsgophpshellsqltestingapidatabasesecurityperformance

Works with

  • api

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned November 22, 2026

npx -y skills add andreibesleaga/GABBE --skill coding --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Coding?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Coding
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-coding-1bb5f4b3/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-coding-1bb5f4b3)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: performant-php
description: "Speed up modern PHP (8.4 and later): OPcache and JIT, worker-mode servers, N+1 fixes, static analysis, tests with Pest. Use when a PHP or Symfony service is slow, or when upgrading PHP versions and tooling."
triggers: [php, php 8.4, php 8.5, composer, symfony, laravel, frankenphp, opcache, jit, phpstan, psalm, pest, phpunit, php performance]
tags: [coding, php, architecture]
context_cost: medium
---
# Performant PHP Skill

## Goal
Build fast, type-safe, maintainable PHP services using the current ecosystem (versions verified 2026-06-10). This is the language-level companion to `performant-laravel.skill.md`; use it for general PHP, Symfony, and framework-agnostic work.

## Capabilities

### 1. Modern language baseline
- **Target PHP 8.4+ (8.5 current stable).** Use **property hooks** and **asymmetric visibility** (8.4) to remove boilerplate getters/setters; **lazy objects** (8.4) for deferred initialization; PDO driver-specific subclasses. On 8.5, the **pipe operator `|>`** chains callables and the built-in **URI extension** parses/normalizes URLs (RFC 3986 / WHATWG).
- Always `declare(strict_types=1);`. Use `readonly` classes/properties, enums (backed where serialized), first-class callable syntax, and constructor property promotion.

### 2. Runtime performance
- **OPcache** must be enabled in production; tune `opcache.memory_consumption`, `opcache.max_accelerated_files`, and `opcache.validate_timestamps=0` (with deploy-time cache reset).
- **JIT** (available 8.3+) more than doubles throughput on CPU-bound work (benchmarks ~+110%); negligible/negative for typical I/O-bound web requests — enable and measure, don't assume.
- **FrankenPHP worker mode** (Caddy-based app server) keeps the framework booted between requests — large latency wins for Laravel/Symfony; also gives Early Hints and real-time (Mercure). Alternative: RoadRunner or Swoole/OpenSwoole.
- Use `preload` for hot framework classes.

### 3. Database & I/O
- Eliminate N+1: eager-load (Eloquent `with()`, Doctrine fetch joins); add covering indexes; use `EXPLAIN`.
- Stream large results with generators (`yield`) to keep memory constant; chunk batch jobs.
- Cache with Redis (PSR-6/PSR-16); use tags and explicit invalidation; queue slow work (Horizon / Symfony Messenger).

### 4. Type safety & quality gates
- **PHPStan** (aim level 8–9) or **Psalm** for static analysis; **Rector** for automated upgrades/refactors.
- **Pint** / PHP-CS-Fixer (PSR-12) for formatting; **Deptrac** for architectural layer enforcement.
- **composer audit** + `roave/security-advisories` to block vulnerable dependencies.

### 5. Testing
- **Pest** (or PHPUnit) for unit + feature tests; PCOV/Xdebug for coverage; HTTP fakes for external calls; Testcontainers / sqlite-in-memory for integration.

### 6. Frameworks
- **Laravel 12** (min PHP 8.2) — see `performant-laravel.skill.md` for Octane/Eloquent specifics.
- **Symfony 7.4 (LTS, supported to 2028/2029)** — autowiring, attributes, Messenger for async, API Platform for APIs; latest line is Symfony 8.x.

## Steps
1. **Baseline**: profile a representative request (Blackfire / Xdebug profiler / `phpbench`) before changing anything.
2. **Enable OPcache + JIT**, measure, then add worker mode (FrankenPHP/RoadRunner) if request boot dominates.
3. **Kill N+1 and add indexes**; cache the verified-hot, rarely-changing reads.
4. **Raise the static-analysis level** (PHPStan/Psalm) and let it fail CI; apply Rector for safe upgrades.
5. **Re-profile** and record the before/after numbers.

## Constraints
- Measure before optimising: no JIT, preloading or worker mode without a before and after profile.
- Check the PHP and framework versions in `composer.json` before using 8.4 or 8.5 syntax.
- Production settings: `display_errors=Off`, `expose_php=Off`, secrets from the environment.

## Output Format
Changed files plus a record of the before and after profile numbers for each optimisation.

## Sources (verified 2026-06-10)
- PHP 8.5 / 8.4 features: <https://www.php.net/releases/8.5/en.php> · <https://php.watch/versions>
- Laravel 12: <https://laravel.com/docs/12.x/releases>
- Symfony 7.4 LTS: <https://symfony.com/releases>
- FrankenPHP: <https://frankenphp.dev/>

## Limits and safety
- Use PDO prepared statements or the ORM's bindings; never put user input into SQL, shell commands (`exec`, `shell_exec`) or `unserialize()`.
- In FrankenPHP worker mode, RoadRunner or Swoole the process outlives the request: reset per-request state (auth, tenant, static caches) so data cannot leak between users.
- Run `composer audit` in CI; changing dependency versions to fix an audit result needs the human's approval.
- Load secrets from the environment, never from committed files.

Files in this skill

  • agent-trajectory-eval.skill.md5.7 KB
  • artisan-commands.skill.md3.7 KB
  • browser-tdd.skill.md7 KB
  • chaos-fault-injection.skill.md8.1 KB
  • ci-autofix.skill.md4.2 KB
  • clean-coder.skill.md4.5 KB
  • code-review.skill.md6.1 KB
  • debug.skill.md6.5 KB
  • documentation.skill.md7.3 KB
  • eval-driven-development.skill.md6.9 KB
  • evals/code-review.eval.yaml1 KB
  • excalidraw.skill.md3.7 KB
  • file-processing.skill.md4.3 KB
  • git-workflow.skill.md7.2 KB
  • metamorphic-testing.skill.md7.8 KB
  • mobile-dev.skill.md4.2 KB
  • nodejs-expert.skill.md1.6 KB
  • output-validation.skill.md5.4 KB
  • pbt-strategy.skill.md8 KB
  • performant-ai.skill.md3.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.