Laravel 10 min read

PHP: production notes

PHP remains the workhorse behind Laravel APIs, automation, and long-lived business apps — with strict typing and discipline where it matters.

Overview

PHP is my default language for fast iteration on server-side logic. Modern PHP (8.3+) with enums, readonly properties, and static analysis closes many of the gaps people still associate with legacy codebases.

How I apply it

  • Favor thin controllers, rich domain services, and explicit DTOs for API boundaries.
  • Use PHPStan/Pint habits so refactors stay safe across modules.
  • Keep autoloading and composer scripts predictable for CI.

Pitfalls I avoid

Mixing business rules into Blade or controllers; ignoring opcache and deploy restarts; skipping tests on “small” validation changes.


See the full skills stack or more writing.

Research snapshot (October 2026)

PHP 8.3+ and 8.4 continue typed property defaults, #[\Override], and performance work on the interpreter without requiring JIT for typical IO-bound Laravel APIs (php.net releases). Laravel 12 (Feb 2025) supports PHP 8.2–8.5; Laravel 13 (2026) raises the floor to PHP 8.3+, which matches how I pin new SuGanta and VedMint deployments.

Where PHP earns a place in Languages

In Languages systems, PHP is valuable when the team can explain why it is there: a measurable outcome (latency, correctness, delivery speed), not resume padding. I treat adoption as a product decision—what breaks if we remove it, and what is the cost of switching?

Production work on EdTech, CRM, and marketplace backends taught me to document the “happy path” and three failure paths before expanding scope. For PHP, that means explicit timeouts, structured logs, and rollback plans when upgrades land.

Architecture patterns that survive audits

Keep HTTP edges thin: validate input, authorize, dispatch to services. Push slow IO (third parties, PDFs, bulk notifications) to queues. Cache read models in Redis when MySQL pressure shows up in slow logs—not before.

When PHP touches PII or payments, segregate duties: operators with export rights are not the same roles that can trigger outbound WhatsApp templates or agent tools. RBAC and audit tables are part of the feature, not an afterthought.

Performance and cost controls

Measure first: APM traces, EXPLAIN on hot queries, queue wait times, cache hit ratio. For IO-bound Laravel APIs, wins usually come from indexing, eager loading, and shrinking payloads—not from micro-optimizing syntax.

Set budgets: max queue depth alerts, per-tenant API rate limits, and circuit breakers on external AI providers. PHP should fail gracefully—degraded mode with a clear user message beats a 504 storm.

Security checklist (backend engineer view)

Validate and sanitize at the boundary; never trust client-side checks alone. Rotate secrets via environment/secret manager; separate dev/stage/prod keys. For JWT/OAuth flows, prefer short-lived access tokens and refresh rotation.

Log security events (login failures, permission denials, webhook signature failures) with correlation IDs. When agents or automations call in, log tool name + tenant + actor, with PII redaction.

Testing strategy that matches risk

Unit-test pure domain logic. Feature-test HTTP endpoints with policy assertions. For integrations, contract-test webhooks and MCP/REST schemas so agent clients do not drift silently.

Before releases, run migrations against a staging snapshot; rehearse queue worker restarts and config cache clears—the boring deploy steps that prevent Friday incidents.

Upgrades, migrations, and team habits

Pin versions consciously: PHP/Laravel/Java LTS alignment, MySQL 8.4, Redis 7.x. Read upstream release notes for deprecations before upgrading production—especially for PHP major versions.

In code review, ask: Does this change need a backfill job? A feature flag? Documentation for support staff? Good Languages hygiene reduces surprise for humans and for automations downstream.

When clients ask for “fast” vs “safe”

Fast wins: CRUD with solid validation, admin panels, reporting exports. Safe wins: payment flows, messaging compliance, multi-tenant isolation, agent write access. PHP can serve both if scope is sequenced—MVP first, hardening second, automation third.

I communicate trade-offs in writing: what we are not doing in sprint one (e.g., full RAG, auto-send WhatsApp) and the trigger conditions to add them later.

Day-zero to day-thirty rollout

Week one: skeleton service, CI, staging environment, and one vertical slice (create → list → show). Week two: authorization matrix, audit logging, and queue workers with Horizon/supervisor dashboards. Week three: performance pass on the top five endpoints and the top three SQL reports.

Week four: runbook, on-call rotation basics, and backup/restore drill. For PHP, document version pins and the next two quarters of upgrade windows so finance and ops are not surprised.

Observability fields I log every time

HTTP: request_id, user id, tenant id, route name, duration_ms, status. Jobs: job_id, queue, attempts, exception class. Integrations: provider status code, sanitized payload hash, retry count.

Dashboards: error rate, queue latency, DB connections, cache memory. Alerts should page humans for payment, auth, and messaging failures—not for every 404 from bots.

Documentation that saves future you

Keep a single ARCHITECTURE.md with diagrams for data flow and trust boundaries. Document env vars with examples (never secrets). Link OpenAPI/Postman collections to the same routes agents will call.

For PHP, capture “known sharp edges” discovered in production—timezone bugs, pagination defaults, charset/collation surprises—so interns and agents inherit the lessons.

PHP version policy I recommend in 2026

Run PHP 8.3 or 8.4 on Ubuntu 22.04/24.04 with opcache enabled in production. Match Laravel’s documented support matrix: Laravel 12 on 8.2–8.5, Laravel 13 on 8.3–8.5. Schedule minor PHP upgrades quarterly; major jumps only after integration tests and queue worker soak time.

Enable declare(strict_types=1); in new modules, use enums and readonly value objects at API boundaries, and run Pint + PHPStan level 6+ on CI so AI-generated patches do not regress type safety.

Frequently asked questions

Is PHP still relevant for new backends in 2026?

Yes when Languages requirements match its strengths—team skills, ecosystem, hosting, and compliance. The decision is contextual, not ideological.

How do I learn PHP for production—not tutorials?

Ship a small service with auth, migrations, queues, tests, and deploy scripts. Read release notes and observe one real slow query fix end to end.

What metrics prove PHP is working?

Error rate, p95 latency, queue age, cache hit rate, and mean time to recovery after deploys—not vanity micro-benchmarks.

How does PHP interact with AI agents?

Expose narrow tools/APIs; never give models raw SQL. Queue LLM calls; audit tool inputs/outputs with tenant scope.

What is the biggest mistake teams make?

Skipping authorization tests and running slow work synchronously on HTTP threads—especially under marketing traffic spikes.

Should I standardize on one language?

Standardize on contracts (OpenAPI, events, idempotent jobs). Polyglot is fine when boundaries are clear.

How do I document PHP for new hires?

Runbooks: local setup, common queues, where secrets live, and three “if prod is on fire” checks.

When should I extract a microservice?

When deployment cadence, scaling profile, or compliance boundary truly differs—not when folders feel messy.

Production readiness scorecard

Use this scorecard in sprint reviews or architecture sign-off. Scores are qualitative—aim for honest “partial” rather than checkbox greenwashing.

Area Question Target state
Observability Can you trace one user request across HTTP, queue, and DB? Correlation IDs everywhere
Security Are authz tests as strong as authn tests? Policies/feature tests per role
Data Do migrations run without full-table locks at peak? Online schema patterns
Reliability Are webhooks idempotent? Unique event IDs + safe replays
Performance Do you know p95 before marketing sends? Load test + slow query budget
Automation Can you disable AI/messaging without deploy? Feature flags + runbooks

Glossary (quick reference)

  • Idempotency — repeating the same request does not double-charge or double-send.
  • Tenant scope — every query filtered by institute/business/account identifier.
  • Tool (MCP/AI) — a typed backend operation agents may call instead of raw SQL.
  • Webhook — provider pushes events to your HTTPS endpoint; you ack fast and queue work.
  • Template message — provider-approved WhatsApp message outside the 24-hour session window.
  • RAG — retrieve documents first, then generate an answer with citations.
  • RBAC — role-based access control mapping users to permitted actions.
  • Sidecar — companion service (e.g., FastAPI) called by the main app over internal APIs.

Before you ship to production

Run through this gate once per release candidate: migrations reversible or forward-only with backfill plan; secrets not in repo; feature flags for automation; load test on top webhooks/endpoints; on-call runbook updated; rollback tested in staging. For PHP 8 backend development, capture a short screen recording of the happy path and one failure path (provider timeout, validation error) so support and new engineers share the same mental model.

Key takeaways

  • Treat PHP 8 backend development as a production discipline: auth, queues, tests, and observability—not a demo script.
  • Prefer narrow tools and idempotent jobs over all-powerful agent prompts.
  • Align version pins with LTS calendars (PHP, Laravel, MySQL, Java) before chasing features.
  • Ship human-in-the-loop messaging and AI drafts before unattended sends.
  • Measure p95 latency, queue age, and override rate—not vanity AI metrics alone.
  • Document runbooks while building; future on-call you is another teammate.
  • Re-read vendor docs (Meta, Laravel, MCP) each quarter—automation rules and rate limits change silently.

Author note

I am Pratik Sahu, a software developer based in New Delhi, India, building Laravel/Spring APIs, multi-tenant EdTech and CRM platforms, and WhatsApp automation backends for production traffic. These articles combine field notes from client work (TyTil, SuGanta, SIEC, VedMint) with current vendor documentation—so you get implementation detail, not generic listicles. If something here helped your architecture review or sprint planning, the best next step is to cross-check the stack version tables below against your LTS policy, then ship one vertical slice with tests and observability before scaling automation or AI scope.

Internal links worth bookmarking

  • Skills stack — how PHP 8 backend development fits my broader toolkit.
  • Work / case studies — products where these patterns shipped under load.
  • Contact — backend, API, or automation consulting.

Stack version comparison (October 2026)

Reference versions I align with when building and deploying systems that use PHP. Compare with your org’s LTS policy before upgrading production.

Technology Current stable Supported range Notes
PHP 8.4.x 8.3 – 8.5 Laravel 13 minimum PHP 8.3
Laravel 13.36.x 13.x Released March 2026; security fixes to Mar 2028
PHPUnit 12.x 11 – 12 Ships with Laravel 13 skeleton

Full stack snapshot

Technology Current stable Supported range Notes
PHP 8.4.x 8.3 – 8.5 Laravel 13 minimum PHP 8.3
Laravel 13.36.x 13.x Released March 2026; security fixes to Mar 2028
Livewire 3.x 3.x Full-page & nested components for Laravel
Java 21 LTS 17 – 21 Common LTS target for Spring Boot 3
Spring Boot 3.4.x 3.2 – 3.4 Jakarta EE 10, Java 17+ baseline
Python 3.12.x 3.11 – 3.13 FastAPI & Celery worker runtimes
FastAPI 0.115+ 0.1xx Pydantic v2 models
MySQL 8.4 LTS 8.0 – 8.4 InnoDB, utf8mb4 default
Redis 7.4.x 6.x – 7.x PhpRedis ext ^4–^6 with Laravel 13
Nginx 1.27.x 1.24+ TLS termination & PHP-FPM proxy
Docker 27.x 24+ Multi-stage PHP/Java images
Node (Vite) 22 LTS 20 – 22 Vite 8 frontend builds on Laravel 13
PHPUnit 12.x 11 – 12 Ships with Laravel 13 skeleton
GitHub Actions — runner ubuntu-24.04 CI matrix PHP 8.3–8.5

Laravel release policy: laravel.com/docs/releases. Package pins: packagist.org/packages/laravel/framework.

Field notes

Modern PHP (8.3+) adds enums, readonly classes, and improved JIT-less performance characteristics that matter more than micro-benchmarks for typical Laravel IO-bound APIs. Official migration guides emphasize deprecations before 9.0.

Return to the skills stack or explore more articles.

AI agents, MCP & automation

PHP is not only for traditional CRUD APIs—it is part of how I ship AI-assisted products and automation safely in production.

PHP/Laravel is where I expose MCP-compatible HTTP tools, signed webhooks, and admin surfaces that agents and humans both use.

How this skill shows up in modern stacks

  • MCP (Model Context Protocol) — expose vetted tools (search listings, create tickets, fetch CRM context) instead of giving models raw database access.
  • AI agents — plan → tool call → verify; Laravel/Spring services enforce business rules after every agent step.
  • WhatsApp automation — Business API webhooks into queues, template broadcasts, and human handoff when confidence is low.

Related reading on this site

MCP for backend engineers · AI agents in production · WhatsApp Business API automation · Webhook-driven AI workflows

When you wire MCP tools, AI agents, or WhatsApp automations, treat PHP with the same discipline as payments or auth: idempotent jobs, explicit scopes, and logs you can audit.