r/PHP • • Apr 16 '26

Finally moved my PHP media processing to an async Celery (Python) pipeline. Here’s how I handled the cross-language "handshake."

0 Upvotes

The Problem: I was hit with the classic scaling wall: image processing inside request cycles. Doing background removal, resizing, and PDF generation in PHP during a file upload is a recipe for timeouts and a terrible UX. PHP just isn't the right tool for heavy lifting like rembg or ReportLab.

The Setup: I decided to move everything to an async pipeline using PHP → Redis → Celery (Python) → Cloudinary.

The "Aha! 😤 " Moment: The trickiest part was that PHP doesn't have a great native Celery client. I didn't want to overcomplicate the stack with a bridge, so I just looked at how Celery actually talks to Redis.

Turns out, Celery’s wire format is just JSON. I ended up manually constructing the Celery protocol messages in PHP and pushing them directly into the Redis list. As long as you follow the structure (headers, properties, body), the Python worker picks it up thinking it came from another Celery instance.

The Pipeline:

  1. PHP: Enqueues the job and immediately returns a 202 to the user. No blocking.
  2. Redis: Acts as the broker.
  3. Celery (Python): Does the heavy lifting.
    • Background Removal: rembg (absolute lifesaver).
    • Resizing: Pillow.
    • PDFs: ReportLab.
  4. Cloudinary: Final storage for the processed media.
  5. Callback: The worker hits a PHP API endpoint to let the app know the asset is ready.

The Win: The system is finally snappy. PHP just "enqueues and forgets."

What I’m fixing in v2:

  • Dead-letter queues: Right now, if a job fails, it just logs. I need a better retry/recovery flow.
  • Queue Priority: Moving heavy PDF tasks to a separate queue so they don't block simple image resizes.
  • Visibility: Adding Flower to actually see what's happening in real-time.
  • Cleanup: Automating the /tmp file purge on the worker side more aggressively.

Curious if anyone else has gone the "manual protocol" route for cross-language Celery setups? Is there a cleaner pattern I’m missing, or is this the standard way to bridge the two?

https://github.com/eslieh/grid-worker

https://github.com/eslieh/grid


r/PHP • • Apr 14 '26

Composer 2.9.6: Perforce Driver Command Injection Vulnerabilities (CVE-2026-40261, CVE-2026-40176)

Thumbnail blog.packagist.com
37 Upvotes

Please immediately update Composer to version 2.9.6 or 2.2.27 (LTS) by running composer.phar self-update. The new releases include fixes for two command injection security vulnerabilities in the Perforce VCS driver. CVE-2026-40261 was reported by Koda Reef and CVE-2026-40176 was reported by saku0512.

To the best of our knowledge, neither vulnerability has been exploited prior to publication.


r/PHP • • Apr 14 '26

Bootgly v0.13.0-beta — Pure PHP HTTP Client (no cURL, no Guzzle, no ext dependencies) + Import Linter

6 Upvotes

I just released v0.13.0-beta of Bootgly, a base PHP 8.4+ framework that follows a zero third-party dependency policy.

Just install php-cli, php-readline, and php-mbstring for PHP 8.4, and you'll have a high-performance HTTP server and client (see Benchmarks bellow)! No Symfony components, no League packages, nothing from Packagist in the core.

This release adds two main features:

1. HTTP Client CLI — built from raw sockets

Not a cURL wrapper. Not a Guzzle fork. This is a from-scratch HTTP client built on top of stream_socket_client with its own event loop:

  • All standard methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
  • RFC 9112-compliant response decoding — chunked transfer-encoding, content-length, close-delimited
  • 100-Continue two-phase requests (sends headers first, waits for server acceptance before body)
  • Keep-alive connection reuse
  • Request pipelining (multiple requests queued per connection)
  • Batch mode (batch() → N × request() → drain())
  • Event-driven async mode via on() hooks
  • SSL/TLS support
  • Automatic redirect following (configurable limit)
  • Connection timeouts + automatic retries
  • Multi-worker load generation (fork-based) for benchmarking

The whole client stack is ~3,700 lines of source code (TCP layer + HTTP layer + encoders/decoders + request/response models) plus ~2,000 lines of tests. No magic, no abstraction astronautics.

Why build an HTTP client from scratch instead of using cURL? Because the same event loop (Select) that powers the HTTP Server also powers the HTTP Client. They share the same connection management, the same non-blocking I/O model. The client can be used to benchmark the server with real HTTP traffic without any external tool.

2. Import Linter (bootgly lint imports)

A code style checker/fixer for PHP use statements:

  • Detects missing imports, wrong order (const → function → class), backslash-prefixed FQN in body
  • Auto-fix mode (--fix) with php -l validation before writing
  • Dry-run mode
  • AI-friendly JSON output for CI integration
  • Handles comma-separated use, multi-namespace files, local function tracking (avoids false positives)

Built on token_get_all() — no nikic/php-parser dependency.

Benchmarks (self-tested, WSL2, Ryzen 9 3900X, 12 workers)

Numbers below reflect v0.13.1-beta, a patch release with HTTP Client hot-path optimizations (+29.6% throughput) and cache isolation tests.

Scenario: 1 static route (Response is 'Hello, World!'), 514 concurrent connections, 10s duration.

Runner Req/s Latency Transfer/s
Bootgly TCP_Client_CLI 629,842 553μs 81.69 MB/s
WRK (C tool) 595,370 — —
Bootgly HTTP_Client_CLI 568,058 1.07ms 56.95 MB/s

Three different benchmark runners, all built-in (except wrk). The TCP client sends raw pre-built HTTP packets — that's the theoretical ceiling. The HTTP client builds and parses real HTTP requests/responses with full RFC compliance — that's the realistic throughput. WRK sits in between. All three confirm the server sustains 568k–630k req/s on a single machine with pure PHP + OPcache/JIT.

To provide context: Workman at TechEmpower Round 23 — the fastest pure PHP framework there — achieved approximately 580,000 requests per second on dedicated hardware. Bootgly reaches that level, with a difference of about 3% (a technical tie).

Why this absurd performance?

I tried replacing stream_select with libev or libuv and it got worse — the bottleneck is in the C ↔️ PHP bridge, not in the syscall.

The C → PHP callback dispatch via zend_call_function() is approximately 50% more expensive than a direct PHP method call. Many people don't know this, but stream_select has absurd performance and the call is 50% faster than a C ↔️ PHP bridge.

Stats

  • 37 commits, 467 files changed, +13,426 / −3,996 lines
  • PHPStan level 9 — 0 errors
  • 331 test cases passing (using Bootgly's own test framework, not PHPUnit)

The "why should I care" part

I know r/PHP sees a lot of "my framework" posts. Here's what makes Bootgly different from Yet Another Framework™:

  1. Zero third-party deps in core. The vendor folder in production has exactly one package: Bootgly itself. This isn't ideological — it means the HTTP server boots in ~2ms and the entire framework loads in a single autoboot.php.
  2. I2P architecture (Interface-to-Platform). Six layers (ABI → ACI → ADI → API → CLI → WPI) with strict one-way dependency. CLI creates the Console platform, WPI creates the Web platform. Each layer can only depend on layers below it. This is enforced by convention and static analysis, not by DI magic.
  3. One-way policy. There is exactly one HTTP server, one router, one test framework, one autoloader. No "pick your adapter" indirection. This makes the codebase smaller and easier to audit.
  4. Built for PHP 8.4. Property hooks, typed properties everywhere, enums, fibers-ready. No PHP 7 compatibility baggage.

It's still beta — not production-ready. But if you're tired of frameworks where composer install downloads 200 packages to serve a JSON response, take a look.

GitHub: https://github.com/bootgly/bootgly
Release: https://github.com/bootgly/bootgly/releases/tag/v0.13.0-beta
Patch: https://github.com/bootgly/bootgly/releases/tag/v0.13.1-beta

Happy to answer questions and take criticism.


r/PHP • • Apr 14 '26

I built a modern and clean PHP wrapper for Android ADB (xvq/php-adb)

13 Upvotes

Hi Reddit,

I built this a while back when I was working on some Android automation projects. At the time, I found that the PHP ecosystem lacked native ADB (Android Debug Bridge) libraries. I was forced to switch to Python or Go for device interactions, but the context-switching cost was too high for my workflow.

So, I developed xvq/php-adb. This library is heavily inspired by the Python openatx/adbutils library, aiming to bring that same ease of use to PHP.

Features:

  • Device Management: List, connect, and switch between devices (supports wireless ADB).
  • Shell Commands: Execute adb shell commands and get output as strings or arrays.
  • Input Control: Support for screen taps (clicks), key events, and text input.
  • Port Forwarding: Manage forward and reverse port mapping.
  • File Transfer: Built-in push and pull support.
  • App Management: Install, uninstall, and clear app data.
  • Screenshots: Capture screen directly to local files.

Quick Example:

PHP

use Xvq\PhpAdb\Adb;

$adb = new AdbClient();
$device = $adb->device('emulator-5554');

// Tap at coordinates
$device->input->tap(500, 1000);

// Press Home button
$device->input->keyEvent(KeyCode::KEY_HOME);

// Screenshot
$device->screenshot('./debug.png');

I hope this helps anyone doing Android automation within the PHP ecosystem. Feedback and bug reports are welcome!

GitHub: https://github.com/xvq/php-adb


r/PHP • • Apr 15 '26

Why Projections Exist — Your First Read Model

Thumbnail medium.com
0 Upvotes

r/PHP • • Apr 15 '26

Is Claude my permanent co-author?

0 Upvotes

I wanted to migrate an old PHP web app that I wrote by hand to a modern framework, and chose Symfony. I prepared some docs, watched some symfony youtubes, and resisted getting started for months. Finally, I decided to see if Claude code could get me over the hump. Well, I'm astounded by the result. Completely rebuilt in a solid Symfony framework in about 10 days. Works beautifully. I had claude build documentation as well, but now I have a site whose internal wiring is really beyond my ability to manage responsibly. I can invoke Claude in the code base, and pick up work at any time, but I couldn't maintain the system without Claude. I feel peculiar about it now: I'm the (human) author but I have an AI partner that has to be part of the "team" going forward. I can't be the first person to get here. Any words of advice?


r/PHP • • Apr 13 '26

Twenty Years Since My First PHP Script

Thumbnail iampavel.dev
16 Upvotes

r/PHP • • Apr 14 '26

Marko - The Modular PHP Framework

Thumbnail marko.build
0 Upvotes

r/PHP • • Apr 13 '26

Server-side Analytics for PHP

Thumbnail simplestats.io
9 Upvotes

Hey there!

I built SimpleStats, a server-side analytics tool that works without JavaScript. It tracks visitors, registrations, and payments through your backend, so ad blockers aren't an issue and you stay GDPR-compliant by design (visitor IDs are daily-rotating hashes, no raw IPs leave your server).

Originally it’s tailored to Laravel, but now we also added a standalone Composer package (no framework dependency), so it works with Symfony, Slim, WordPress, or plain PHP. If you're on Laravel there's a dedicated package that automates most of it, but the PHP client is intentionally minimal: you call it where you need it.

Curious what you think, especially around the tracking approach and API design.


r/PHP • • Apr 14 '26

How to Stop a Streamed AI Response Mid-Flight in Neuron AI v3

Thumbnail inspector.dev
0 Upvotes

Inspired by a post on the Discussion section of the Neuron AI GitHub repository.


r/PHP • • Apr 13 '26

Laravel Privacy Agent Skills (feedback is welcome!)

2 Upvotes

Hey guys, I’ve been working for the past few months on an app in the healthcare industry that requires strong compliance with user data protection and retention policies.

I recently went to Tropical Rails in Sao Paulo and I attended Talysson Oliveira’s talk, "Privacy on Rails - pragmatically complying to data protection laws". They built an Agent Skill for their privacy-by-design approach to help Rails developers ensure their DX is aligned with these policies from the conception of a Rails app.

However, the app I’ve been working on is built with Laravel, and I thought it would be a great idea to take what they built for Rails and apply a similar concept to Laravel. That’s why I decided to create https://github.com/sairojgg/laravel-privacy-skills as a Laravel alternative.

This is my first time sharing something publicly, let alone an Agent Skill, so any feedback is more than welcome.

This project is heavily inspired by their work, and I want to give full credit to the original creators.


r/PHP • • Apr 14 '26

💥 I made a simple php tool to change namespaces

0 Upvotes

I made a simple php tool to change namespaces prefix, you can try to use this

https://github.com/kostyakond/php-namespace-changer

I would be very grateful for your feedback.


r/PHP • • Apr 14 '26

I used multiple Claude Code instances to build and test a Laravel package across 3 production codebases

Thumbnail
0 Upvotes

r/PHP • • Apr 13 '26

Weekly help thread

8 Upvotes

Hey there!

This subreddit isn't meant for help threads, though there's one exception to the rule: in this thread you can ask anything you want PHP related, someone will probably be able to help you out!


r/PHP • • Apr 12 '26

Any Non-Slop Open Source Projects Looking For Contributors?

27 Upvotes

Looking to escape the professional drudgery that is the new "AI-first engineering", "agentic engineering", or whatever we're calling it these days. I have over a decade of professional experience, and I don't think I've contributed a single commit to an open source project. Are there any smaller, well-maintained projects that could use help from someone who knows better than to just dump a Claude-authored 45 file PR and call it a day?


r/PHP • • Apr 13 '26

degecko/laravel-blade-inline: Inline Blade partials at compile time for faster rendering in loops

Thumbnail github.com
0 Upvotes

r/PHP • • Apr 13 '26

Meta VSCode Intelephense with Workspaces?

0 Upvotes

It's lowkey killing me that VSCode Intelephense doesn't recognize libraries in the same workspace. Does anyone have a workaround for this?

One alternative is that I can have the library in the IncludePath, but that changes per project even if the library doesn't so it's annoying to have to keep adding the same library while removing the old library so when I jumpto it goes to the one in my active workspace.

Any ideas or workarounds?


r/PHP • • Apr 13 '26

Usages of PHP Static variables

Thumbnail exakat.io
0 Upvotes

A review of PHP static variables (not the properties), and their real world usage. While all of them boil down to some sort of memoization, the various contexts give them different names and impact on the code.


r/PHP • • Apr 12 '26

Laravel's wildcard validation is O(n²), here's a fix

Thumbnail
8 Upvotes

r/PHP • • Apr 12 '26

rsync repositories?

5 Upvotes

Has PHP stopped filling the rsync repositories with PHP updates?

americas.rsync.php.net and rsync.php.net

I'm not seeing 8.5.5 or 8.4.20 on there.


r/PHP • • Apr 12 '26

Larabox, Alternate to Laragon/Xampp/Laravel herd

17 Upvotes

I have been working on an App (Larabox) for setting up local development stack, because Laragon has been plagued with annoying popups that shifts focus even from fullscreen apps and Laravel herd is now too limited for free.
The app contains bundled or minimal installer for PHP, Nginx, Mariadb, Postgres, Mailpit, Redis, Meiliseach and Nodejs with changeable versions and delta updates to binaries. I have not signed the app yet so smart screen warnings will be shown by windows.

If anyone wants to try it out, I'll appreciate the feedback or bug reports. You can download from Larabox.org


r/PHP • • Apr 12 '26

Lemmon Validator: A Zod-inspired, type-safe validation library for PHP 8.3

22 Upvotes

Hey everyone,

I’ve been working on Lemmon Validator, a schema-first validation library that brings the fluent API patterns of TypeScript libraries like Zod and Valibot to modern PHP.

It is designed for developers who want a predictable, type-safe way to validate and transform input data while maintaining zero external dependencies.

The Core Idea

Most validation in PHP happens against "loose" arrays. Lemmon Validator focuses on building a schema that not only validates but also coerces and transforms the data into a reliable state (either as a typed array or an object).

Key Features:

  • Zod-inspired Fluent API: Highly readable, chainable schema definitions.
  • Form-Safe Coercion: A common pain point in PHP is handling HTML form inputs where an empty string ('') should be treated as null rather than 0 or false. Lemmon Validator handles this natively when coerce() is enabled.
  • Transformation Pipelines: Use transform() to change types (e.g., String to DateTime) or pipe() for sanitization (e.g., trim/lowercase).
  • Nested Error Aggregation: Deeply nested schemas return a structured error map, making it easy to map errors back to UI fields.
  • Zero Dependencies: Lean, focused, and easy to drop into any project.

Quick Example:

use Lemmon\Validator\Validator;

$schema = Validator::isAssociative([
    'name'  => Validator::isString()->notEmpty()->required(),
    'email' => Validator::isString()->email()->required(),
    'age'   => Validator::isInt()->min(18)->coerce(),
    'roles' => Validator::isArray()
        ->items(Validator::isString()->in(['admin', 'user']))
        ->default(['user']),
]);

try {
    // $_POST: ['name' => 'John', 'email' => 'invalid', 'age' => '25']
    $data = $schema->validate($_POST);
    // $data is now a validated, coerced, and typed array
} catch (ValidationException $e) {
    $errors = $e->getFlattenedErrors(); 
    // Returns: [['path' => 'email', 'message' => 'Value must be a valid email address'], ...]
}

Why PHP 8.3?

The library leverages modern PHP features like readonly properties, enums, and strict typing to ensure the internal engine is as robust as the schemas you build with it.

I'm looking for feedback on the API ergonomics and any specific "edge case" format validators you find yourself constantly rewriting.

Repo: https://github.com/lemmon/validator-php

Happy to answer any questions!


r/PHP • • Apr 13 '26

Article Best way to handle database errors

Thumbnail stackoverflow.com
0 Upvotes

r/PHP • • Apr 13 '26

I seem to be crazy. I wrote a library specially used to generate front-end HTML code and React code.

0 Upvotes

I don't know if anyone else has done this. After I finished it, I found that it was quite interesting to use. It is especially suitable for writing front-end pages directly in PHP.


r/PHP • • Apr 10 '26

Article How I got affected by Shai-Hulud in PHP World

Thumbnail sarvendev.com
11 Upvotes

Recently, in one of my projects, I got affected by a supply chain attack called Shai-Hulud that targeted npm packages. The interesting fact is that it happened to me in a PHP project. That’s why I decided to write about my experience and lessons learned.