r/PHP • • 3d ago

Weekly help thread

4 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 • • 7d ago

Who's hiring/looking

18 Upvotes

This is a bi-monthly thread aimed to connect PHP companies and developers who are hiring or looking for a job.

Rules

  • No recruiters
  • Don't share any personal info like email addresses or phone numbers in this thread. Contact each other via DM to get in touch
  • If you're hiring: don't just link to an external website, take the time to describe what you're looking for in the thread.
  • If you're looking: feel free to share your portfolio, GitHub, … as well. Keep into account the personal information rule, so don't just share your CV and be done with it.

r/PHP • • 2h ago

Article What PHP’s session vulnerability teaches us about atomicity

0 Upvotes

PHP’s recent session-file vulnerability, CVE-2026-126714, highlights an easy-to-miss distinction: file locking prevents competing writers, but it doesn’t make a write atomic.

If a session write is interrupted, the file can end up containing a prefix of the new serialized session followed by leftover bytes from the old one. Under the right conditions, that can turn corrupted session data into remote code execution.

I wrote about what happened, how PHP fixed it by truncating the file before every write, and why a lock isn’t the same thing as a transaction.

Read the article: https://amitmerchant.com/what-phps-session-handler-teaches-us-about-atomicity/


r/PHP • • 10h ago

Creating a roaring bitmap extension

Thumbnail github.com
4 Upvotes

r/PHP • • 18h ago

Arco: an open-source CLI to deploy PHP to AWS Lambda Web Functions with FrankenPHP (MIT)

Thumbnail github.com
11 Upvotes

Hi r/PHP. We've been building Arco, an open-source CLI written in PHP that deploys PHP apps to AWS Lambda Web Functions, and we'd like feedback from people who run PHP in production.

**What's different about Web Functions**

AWS launched Lambda Web Functions in October 2026. Unlike classic Lambda, where one instance handles one request at a time, a Web Function runs your app as a normal HTTP server: it listens on a port and one instance handles many requests concurrently (64 by default, up to 128). That fits PHP's long-running worker model well, so Arco runs your app on FrankenPHP in worker mode. The framework boots once per instance, not once per request.

It still scales to zero, and there's no minimum instance setting, so the first request after an idle period pays a cold start.

**What Arco does**

composer require --dev multiapi/arco

vendor/bin/arco init

vendor/bin/arco deploy --env=production

`arco deploy` builds a copy of your project, packages it with a pinned FrankenPHP arm64 binary, uploads it, creates a new revision, shifts traffic, checks a health route and rolls back if it fails. No Docker and no Node.js on your machine.

Everything is configured in one plain PHP file, `arco.php`:

return App::make('shop')

->region('us-east-1')

->environment('production', fn (Environment $env) => $env

->domain('shop.example.com')

->queue('emails')

->storage('uploads')

->scheduler(1)

->variables([

'APP_KEY' => 'arco-ssm:/shop/production/app-key',

]));

From that file it sets up:

- Environments, each its own function

- Secrets as SSM / Secrets Manager references, resolved at start-up, with IAM scoped to exactly what you reference

- SQS queues with a dead-letter queue and a worker function

- S3 buckets and DynamoDB tables for storage and cache

- Custom domains: certificate, CloudFront and DNS records (Route 53, Cloudflare or DNS you manage yourself)

- A console function for running commands, a REPL and migrations before traffic moves

- A scheduler on EventBridge

**Honest limitations**

- It's young. Web Functions are weeks old and so is most of this.

- Laravel (11+, with Octane) is the first-class path today. That's where the preset, queues and scheduler integration live.

- AWS only, and only the regions where Web Functions are available.

- Worker mode means the usual long-running PHP caveats: state leaks between requests if your code or a dependency isn't written for it.

**Requirements:** PHP 8.3+, Composer, an AWS account.

Repo: https://github.com/multi-api/arco

Docs: https://github.com/multi-api/arco/tree/main/docs

Disclosure: we're the authors. We also run a hosted dashboard on top of it, but the CLI is MIT and deploys straight into your own AWS account without it.

What we'd most like to hear: does the `arco.php` API read well to you, and what would stop you from trying this on a real app?


r/PHP • • 14h ago

Discussion Running PHPCompatibility inside WordPress without exec(): what I learned

2 Upvotes

I wanted a PHP 8.x compatibility check that works on shared WordPress hosting, where you can't run phpcs from the command line and requests time out after 30 seconds. So I ended up running PHP_CodeSniffer and PHPCompatibility inside a plugin. A few things I had to solve:

- Scoping the bundled PHPCS with PHP-Scoper so it doesn't clash with other plugins, and fixing the cases where Scoper prefixes strings it shouldn't (class names that are data, like Random\Randomizer).

- A Config subclass that never reads argv or STDIN, since there is no CLI.

- Splitting the scan into chunks of a few seconds, saved in the database, so it can stop and resume.

- Telling real problems apart from code that is already wrapped in a PHP version check.

Happy to go into detail on any of these.


r/PHP • • 5h ago

Drupal vs WordPress 2026-2027: Which Should You Choose?

Thumbnail coresis.co
0 Upvotes

r/PHP • • 1d ago

News PHP Debugger - Agentic zero-overhead debugging

54 Upvotes

Hi, I wanted to introduce PHP debugger, a tool I built together with Roman Pronskiy, former Executive Director of The PHP Foundation and former head of PhpStorm at Jetbrains.

We took Xdebug and removed everything that was not related to debugging and optimised to death the case where the debugger was enabled but not connected, and were able to achieve near zero-overhead.

This means that instead of having to enable and disable or trigger the debugger all the time, you can leave it permanently on, ready to start a debugging session when you need it and out of the way when you don't.

And this has also allowed us to build an MCP server that connects to the debugger and which can be used by agents to debug PHP code in the same way that humans do, setting breakpoints, reading values and stepping through the code.

This raises the possibilities of agentic debugging to a new level and allows your agents to fix issues with precision and without any wild guesses.

PHP debugger is really easy to install, so why don't you give it a go and let us know what you think? https://github.com/php-debugger/php-debugger


r/PHP • • 12h ago

Laravel Safe Migrations v1.1: catch dangerous migrations before they hit production (updated with your feedback)

0 Upvotes

Hi everyone,

A while ago I shared Laravel Safe Migrations, a package that checks your pending migrations for things that can break production before you run migrate. Thanks for all the feedback last time. Several suggestions from that thread are now in the package.

How it works

It dry-runs your pending migrations in Laravel's pretend mode, collects the SQL they would execute, and checks it against a set of rules. Because it reads the SQL and not your PHP code, it also catches DB::statement(), DB::unprepared() and query builder calls.

php artisan safe-migrations:check ERROR [drop-column] Dropping column [users.legacy] destroys its data, and app servers still running the old code will fail on queries that use it. → Remove every use of the column from the code and deploy that first, then drop the column in a follow-up migration. What it catches

Dropping or renaming tables and columns that the old code still uses during the deploy NOT NULL columns without a default on tables that already have rows Column type changes that rewrite the whole table PostgreSQL: blocking CREATE INDEX, foreign keys without NOT VALID, and SET NOT NULL UPDATE / DELETE without WHERE, and TRUNCATE Tables created earlier in the same batch are ignored, since they have no data yet New since last time

concurrent-in-transaction rule: flags CREATE INDEX CONCURRENTLY in a migration that Laravel wraps in a transaction, which PostgreSQL rejects. The fix is public $withinTransaction = false;. (Suggested in the last thread, thanks!) Side effects are faked during the check: HTTP calls, mail, notifications, queued jobs and dispatch() inside up() no longer actually happen while the migration is analysed. Migrations with their own $connection are now checked against the right database. SQL comments can't hide a statement from the check anymore. Three ways to use it

In CI: safe-migrations:check fails the pull request if a migration is unsafe. In deploys: php artisan migrate:safe --force checks first, then migrates. As a guard: set SAFE_MIGRATIONS_GUARD=true and plain migrate refuses unsafe migrations in production. When a risky change is intentional, mark the migration so the reason stays in code review:

return new #[AllowUnsafe('drop-column', reason: 'unused since v2.3')] class extends Migration { ... }; Honest limitations

Pretend mode returns no data, so a migration that branches on Schema::hasColumn() is checked along the "empty" path. It can't know your table sizes. A warning on a 200-row table may not matter. File and cache writes inside up() still run during the check. Supports Laravel 12/13 on MySQL/MariaDB, PostgreSQL and SQLite. SQL Server isn't supported. Install

composer require hamza-wakrim/laravel-safe-migrations GitHub: https://github.com/Hamza-Wakrim/laravel-safe-migrations

I'd love feedback, especially false positives or problems it missed on your real migrations, and rule ideas from your zero-downtime deploys. MySQL lock detection (instant vs. table-copy changes) is next on my list.


r/PHP • • 15h ago

News Update: MicroUnit got featured on Laravel News and phpnews.net

0 Upvotes

A couple of days ago I posted about MicroUnit, a dependency-free PHP testing framework.

And today was a big day for it.

First it got featured on Laravel-News, which was already a nice milestone.

But then: I sent a tip to Eric Barnes, the founder and editor of Laravel News and phpnews.net, about the 1.0 release, and he wrote an article about MicroUnit himself.

It's already live: https://phpnews.net/microunit

I just wanted to say thanks to everyone who gave me feedback for MicroUnit and helped me make the framework better over the last few days.

If you wanna try out MicroUnit:


r/PHP • • 1d ago

php-wasm-builder 1.0: compile PHP to WebAssembly, with your extensions and your code, and run it in the browser

Thumbnail blog.lyrixx.info
18 Upvotes

r/PHP • • 23h ago

Does a framework need AI features in its core, or is explicit code enough for AI assistants?

Thumbnail getlaminas.org
0 Upvotes

AI coding assistants need context to perform as expected. The Laminas Project published an article about Mezzio with the opposite position. The article says that Mezzio does not need AI in its core, because the AI reads the code and follows it.

It argues that:

  • Configuration is explicit, in PHP files under config/.
  • Conventions are consistent. Handlers and middleware use PSR-15 interfaces, and each module has a ConfigProvider and factories
  • Tests and standards check the result. The skeleton includes PHPUnit and PHP_CodeSniffer, and ‘composer check’ runs both on code from humans and from AI.
  • The AGENTS.md file can be short, highlighting only the config files, mezzio-tooling, and the checks.

Ultimately, the questions are:

  • Can you safely rely on auto-discovery and ‘magic’?
  • Does the AI agent need guidance via AGENTS.md / CLAUDE.md files before you let it touch the code?
  • How do you review AI-generated code in your PHP projects?

r/PHP • • 1d ago

el2sql: Translator from Symfony's ExpressionLanguage to SQL (Postgres dialect)

10 Upvotes

One of the first examples in ExpressionLanguage docs is

# Promote article to the homepage when
article.commentCount > 100 and article.category not in ["misc"]

Assuming we want to find all promoted articles, it is possible to fetch all articles from the database and check them with $expressionLanguage->evaluate(). The nicer approach is to delegate this to the database, of course.

Given the above expression, sad_spirit/el2sql can generate something like

select self.*
from example.articles as self left join lateral (
        select count(comment_id) as comment_count
        from example."comments" as c
        where not comment_hidden
            and c.article_id = self.article_id
    ) as ac on true
where ac.comment_count > 100
    and self.article_category <> all(array['misc'])

This is done by taking the AST of the expression created by ExpressionLanguage and transforming it to AST for Postgres represented using classes from sad_spirit/pg_builder. The package is able to transform basic stuff (property -> column) automatically, while custom properties like commentCount above, custom functions, etc. will require custom translators.

Answers to obvious questions:

  • Purpose of the library: the original version was written for a home-grown ABAC implementation that used ExpressionLanguage for writing policies. Immediately requested features were
    • Show all resources that can be processed by the given employee (AKA "requires my attention" checkbox);
    • Show all employees that can process the given resource (AKA "who's responsible for a delay").
  • AI usage: no stochastic parrots were harmed in the making of this library.
  • Why depend on PHP 8.2 instead of new shiny PHP 8.6? The dependencies work on PHP 8.2.

r/PHP • • 20h ago

Larger web apps

0 Upvotes

I am researching what an effective process would be to keep a larger web app in check, from the design perspective. Some redesign has me at 50 screens already, across about 10 modules. Since I am not into react, using sing chat:

> Framework: Laravel — The gold standard for PHP SaaS. Its Blade templating engine lets you build reusable UI components (<x-button>, <x-sidebar>) just like React, keeping 50+ screens DRY (Don't Repeat Yourself).

Can this be challenged, are there some other packages you'd use? I've always been partial to something like smarty syntax template engines and kept a profile closer to stdlib, and some difference of opinion as to if a button component is needed or you just use html as a normal person.

With so many screens, do you find that something like figma is generally better aside just directly coding things today with a LLM and trying to enforce hellish organisational structure? Considering design refinement is then basically an integrated live-app process.


Tl:dr: I will not consider react because i will not run the node runtime. It's a PHP group my guy in the comments

If you had a large web app with 50 unique screens and are interested in managing previews and review the designs:

  • would you use anything but laravel to write the framework and what
  • would you still get designs as figma source
  • do you integrate something other than figma for user flow mapping

Thanks


r/PHP • • 1d ago

News KnpSnappy, laravel-snappy and phpwkhtmltopdf without the archived wkhtmltopdf: the same command line on a current Chromium

Thumbnail github.com
1 Upvotes

wkhtmltopdf is archived: its last release dates from June 2020, on a Qt WebKit that gets no security fixes, and Debian 13 no longer ships it. KnpSnappy, laravel-snappy and phpwkhtmltopdf still call it.

I made PDFKiln to take its place: the same command line (the 122 options of wkhtmltopdf 0.12.6, with its defaults, messages and exit codes), rendered by a current Chromium with its sandbox on. On 32 real templates (Odoo, ERPNext, Sylius, pandoc), all 32 keep their page count and 99.2 % of the words stay on the same page. The test suites of laravel-snappy and phpwkhtmltopdf pass with it.

With Composer, the program is fetched on first use and checked against its SHA-256:

composer require pdfkiln/pdfkiln knplabs/knp-snappy

$snappy = new \Knp\Snappy\Pdf(\Pdfkiln\binary());

Called as pdfkiln, it also does what wkhtmltopdf never did: PDF/A and Factur-X/ZUGFeRD invoices, Markdown, images, PDF inputs after the page (terms of sale after an invoice) and password-protected PDFs.

Source (MIT): https://github.com/pdfkiln/pdfkiln. Guide: https://pdfkiln.org/migrate/knp-snappy/. I'm the author: a template that comes out differently from wkhtmltopdf is the feedback I'm after.


r/PHP • • 2d ago

XMLReader::setSchema() takes almost two minutes on a 20 MB base64 element (quadratic in libxml2)

22 Upvotes

If you validate large XML with XMLReader and an XSD, one big text node can stall it for minutes. E-invoices hit this all the time: the invoice PDF is embedded as base64 in a single element, so a 15 MB PDF becomes a 20 MB text node.

Timings with PHP 8.5 and libxml2 2.9.13, a schema with one xs:base64Binary element:

base64 element XMLReader + setSchema() DOMDocument::schemaValidate()
5 MB 6.3 s 0.01 s
10 MB 26 s 0.02 s
20 MB 109 s 0.04 s

Double the size, four times the time.

The cause is in libxml2, not PHP. In streaming mode the parser hands text to the schema validator in chunks of a few hundred bytes, and xmlSchemaVPushText glues each chunk onto the value with xmlStrncat, which runs strlen over everything so far and reallocates it every time. Tree validation (what DOMDocument::schemaValidate does) gets the text in one piece and never takes that path. libxml2 2.15.4 still does it.

What you can do today:

  • If the document fits in memory, validate with DOMDocument::schemaValidate() instead.
  • If it doesn't (that's why you used XMLReader), there's no setting that avoids it; it needs a libxml2 with the fix. I sent one upstream (keep the length, grow the buffer geometrically; linear again): https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/471

Write-up with the profiling and the patch: https://xmlvalid.com/blog/a-quadratic-loop-in-libxml2-xsd-validation


r/PHP • • 1d ago

What do you think the new Laravel announcement will be?

Thumbnail
0 Upvotes

r/PHP • • 1d ago

Phast: a drop-in Composer alternative or a "design & speed reference"?

0 Upvotes

Mhm, less than two weeks after the beta release, Phast is already somebody's "speed reference" and "design reference".

Spotted in another Rust PHP toolchain's planning notes:

"What we learnt from phast and Composer": "phast (github.com/phast-sh/phast, Rust, MIT or Apache-2.0, 9 crates, about 45k lines) is the speed reference"

I was really surprised that even the number of crates was counted :) That's quite serious attention to detail.

The TOML manifest made it about 20 hours over there, but workspaces with one lock and one vendor/, well, are still going strong. Inspiring others wasn't really the plan, but feels like a nice bonus 😄

The moral of the story: two engineering degrees, years of work and tons of books, all to become a "design reference". Worth every minute!


r/PHP • • 1d ago

News Public beta for Pun which is ultrafast unified PHP toolchain.

0 Upvotes

hey all

been working on this thing called pun. it's one binary that does format, lint, analyse and composer install for php projects, all from one pun.toml

quick rundown:

pun format - only touches layout, never what the code does

pun lint --fix - rewrites stuff to a better way, fixes are marked safe/unsafe

pun analyse - finds bugs, never edits anything

pun install - fills vendor/ from your composer.lock

pun migrate - turns your pint.json / rector.php / phpstan.neon into one pun.toml

the code is 100% AI generated but tested over months. not gonna pretend otherwise

it's a beta so there will be bugs. if you try it on a real project and something breaks or feels off, tell me, that's the whole point.

if you don't wanna try it, all good too.

repo: https://github.com/shipfastlabs/pun

docs: https://punphp.com


r/PHP • • 1d ago

Discussion Iniciando no PHP

0 Upvotes

Bom dia, boa tarde ou boa noite, eu sou muito novo na área de desenvolvimento, atualmente estou fazendo um curso de analise e desenvolvimento no Senac de minha cidade, o curso é muito bom e muito interessante, ainda estamos no começo mas tenho gostado muito de elaborar projetos, mas confesso que sempre tive uma forte paixão por design web, e gostaria muito de me aprofundar, estudei um pouco de CSS + HTML + JavaScript, mas muito me tem chamado a atenção o PHP, uma linguagem sólida no mercado, porém me encontro com muita dificuldade em encontrar o ponto inicial para começar a estudar, o PHP vem recebendo muitas atualizações, então tenho medo de começar a ver um curso que foi feito em 2023 por exemplo e muita coisa ter mudado, por não ter muito repertorio sobre a área, não sei aonde encontrar um bom curso, então venho por meio desta postagem solicitar um norte da comunidade. desde já muito grato.


r/PHP • • 3d ago

⚡ Meet turbocov: a PHP code coverage engine with 400× less overhead than Xdebug

Thumbnail github.com
4 Upvotes

Code coverage in PHP has always been painfully slow. PCOV doubles the time of a test suite, Xdebug makes it 13× slower. So most teams collect coverage once a night, or never.

I built turbocov, a PHP extension that collects line coverage at near-native speed!

The numbers (Carbon test suite, 6,349 tests, PHP 8.5, driver overhead only):

Driver Time Overhead
no coverage 18.7 s –
turbocov 19.3 s +3 %
PCOV 36.7 s +96 %
Xdebug 250 s +1237 %

The benchmark is in the repo, so you can run it yourself.

How can it be so fast?

PCOV and Xdebug run a check before every single opcode. Forever. That slows down everything: your code, your vendor libraries and PHPUnit itself.

turbocov puts a one-shot probe on the first opcode of each line. The probe fires once, records the line, and puts the original handler back. From then on, the line runs at plain PHP speed.

ZERO overhead for code you don't measure!

Only the files in turbocov.collect_paths get probes. Vendor runs untouched at plain PHP speed!

And it's even more precise than PCOV and Xdebug

Mainly in multi-line expressions.

Try it (PHP 8.4+, PHPUnit 13.3+, Linux and macOS):

pie install shipmonk/turbocov
composer require --dev shipmonk/turbocov-phpunit

and one line in phpunit.xml:

<coverage driver="ShipMonk\Turbocov\TurbocovDriver"/>

Older PHPUnit? There is a PCOV-compatible mode.

The honest part: line coverage only (no branch or path coverage), CLI only, no Windows, it cannot run with some OPcache settings like JIT or the optimizer.

I'd love to hear how it does on your codebase: benchmarks, bug reports, edge cases, all welcome!


r/PHP • • 2d ago

I built a tool that recovers readable PHP source from encoded files / ZIP projects — free single-file test

0 Upvotes

Lost your PHP source? Inherited a project with no source, or files encoded with ionCube / SourceGuardian? iDecode recovers readable source from encoded PHP files and whole ZIP projects. Upload one file, preview it free in the browser, and review the ZIP inventory and cost before you confirm a project. https://idecode.ir/ | App: https://app.idecode.ir/ — I'm the owner, happy to answer how the preview / ZIP inventory works.


r/PHP • • 4d ago

Ondrej's php repository move

141 Upvotes

If you used Ondrej's lauchped repo on Ubuntu - it has been retired and will receive no more patches.

Ondrej, the man the myth the legend, moved it to his own repo.

grep -ir ondrej /etc/apt/sources.list.d/

For 22.04 (replace jammy with noble for 24.04)

sudo curl -fsSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ jammy main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update

r/PHP • • 2d ago

Discussion I released MicroUnit 1.0, a zero-dependency testing framework. I'd like critical feedback on it.

0 Upvotes

MicroUnit is a PHP testing framework where a test is a closure with a name, and nothing gets installed besides MicroUnit itself:

$tester = TestSetup::getTester('Cart');

$tester->define('applies_the_discount_to_the_total', function (): void {
    $cart = new Cart();
    $cart->add('book', price: 2000);

    $cart->applyDiscount(percent: 10);

    Assert::exact(1800, $cart->total());
});

What's in the box: static or fluent assertions, mocks, snapshots, code coverage in pure PHP (no Xdebug or PCOV), parallel runs, a Test Explorer in the browser, Laravel/Symfony/CodeIgniter integrations, and microunit migrate, which translates a PHPUnit suite and leaves the original untouched.

Edit: Since I've seen some interest for the included agentic support I want to link the page that contains the detailed explanation for that feature: https://mitarnik04.github.io/MicroUnit/ai-agents/

Some things you should know before you judge it:

  • It's written with AI. I decide the design and review every change; AI writes most of the code, tests and docs. I documented how the quality is kept up (12 CI runs per change, PHPStan at max, a canary, a check that flags weakened tests, real projects' suites before a release): https://mitarnik04.github.io/MicroUnit/quality-with-ai/
  • It needs PHP 8.5 or newer. That rules out a lot of projects today, I know.
  • The benchmarks come from one laptop, run against migrated suites of six real projects (method, raw data and every exclusion are published). MicroUnit was faster in all 24 comparisons, but it uses more memory on nesbot/carbon because migrate copies inherited tests into every subclass (there's an open issue for that): https://mitarnik04.github.io/MicroUnit/benchmarks/
  • It's not trying to replace PHPUnit. PHPUnit is what PHP testing is built on. MicroUnit's framework integrations even run inside the frameworks' own PHPUnit-based test cases.

What I'd most like feedback on: whether the API reads well to you, what you'd miss coming from PHPUnit or Pest, and anything in the quality process that you think doesn't hold up.

Repo: https://github.com/mitarnik04/MicroUnit Docs: https://mitarnik04.github.io/MicroUnit/


r/PHP • • 2d ago

Bun for PHP - Pun - is coming, WDYT?

Thumbnail x.com
0 Upvotes

Javascript has Bun - a one-all tool that handles cs, linter, format, transpiling (and more).

Pun whould handle the same: including static analysis, refactoring, upgrades in fraction of a second.

Would you switch to such a tool? Are you already using ECS Blink or PHPStan turbo? What's your take on this?