r/PHP • u/brendt_gd • 3d ago
Weekly help thread
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 • u/brendt_gd • 7d ago
Who's hiring/looking
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 • u/cpollett • 5h ago
Yioop 10: a PHP search engine and wiki system, now with its own mail and git servers
Yioop is a GPLv3 search engine and wiki system in PHP that I have worked on since 2009. Version 10 is now out, and both parts have been extended.
One of the design goals of Yioop has been to keep its dependencies on other projects and libraries to a minimum. In version 10 more of what a site needs is done in Yioop's own PHP code:
- Web server. Yioop has had its own web server for a while, but it was not used in production. In version 10 it is ready for production use, with HTTPS, HTTP/2 and HTTP/3, and it gets and renews its own certificates from Let's Encrypt over ACME. Yioop can still be run under Apache or nginx.
- Mail server. Yioop has its own mail server, so one PHP install can serve a site and deliver its mail.
- Audio and video. Common audio and video formats are decoded and encoded in Yioop's own PHP code, and users can make voice and video calls from their messages.
- Git. A wiki page can hold a git repository that people clone and push to over HTTP, with an issue tracker beside it.
- Security and testing. A security review went over every url path Yioop answers, and the URL Types page (https://www.seekquarry.com/p/URL_Types) lists each one, its arguments and who may call it. Security tokens are now keyed SHA-256 hashes compared in constant time, the session cookie is HttpOnly and SameSite, and the wiki parser was rewritten so markup crafted to inject scripts is drawn safely. Administrators can set password rules and choose local or LDAP sign-in. The unit tests grew from 115 test cases in 43 files at version 9.4 to 1,546 cases in 185 files.
On the search side, Yioop comes with a crawler for the open web or for a list of sites you choose. It can also index Wikipedia XML dumps, arc and warc archives, and dumps of email or databases. On the wiki side, users can run discussion groups, blogs and wikis, and the wiki can build whole web sites.
Yioop is built on a Model View Adapter framework which can be extended into a custom search portal. Its stemmers, summarizers and other language tools can be used in your own project through Composer:
composer require seekquarry/yioop
Demo: https://www.yioop.com/
Docs and downloads: https://www.seekquarry.com/Yioop is a GPLv3 search engine and wiki system in PHP that I have worked on since 2009. Version 10 is now out, and both parts have been extended.
One of the design goals of Yioop has been to keep its dependencies on other projects and libraries to a minimum. In version 10 more of what a site needs is done in Yioop's own PHP code:
- Web server. Yioop has had its own web server for a while, but it was not used in production. In version 10 it is ready for production use, with HTTPS, HTTP/2 and HTTP/3, and it gets and renews its own certificates from Let's Encrypt over ACME. Yioop can still be run under Apache or nginx.
- Mail server. Yioop has its own mail server, so one PHP install can serve a site and deliver its mail.
- Audio and video. Common audio and video formats are decoded and encoded in Yioop's own PHP code, and users can make voice and video calls from their messages.
- Git. A wiki page can hold a git repository that people clone and push to over HTTP, with an issue tracker beside it.
- Security and testing. A security review went over every url path Yioop answers, and the URL Types page (https://www.seekquarry.com/p/URL_Types) lists each one, its arguments and who may call it. Security tokens are now keyed SHA-256 hashes compared in constant time, the session cookie is HttpOnly and SameSite, and the wiki parser was rewritten so markup crafted to inject scripts is drawn safely. Administrators can set password rules and choose local or LDAP sign-in. The unit tests grew from 115 test cases in 43 files at version 9.4 to 1,546 cases in 185 files.
On the search side, Yioop comes with a crawler for the open web or for a list of sites you choose. It can also index Wikipedia XML dumps, arc and warc archives, and dumps of email or databases. On the wiki side, users can run discussion groups, blogs and wikis, and the wiki can build whole web sites.
Yioop is built on a Model View Adapter framework which can be extended into a custom search portal. Its stemmers, summarizers and other language tools can be used in your own project through Composer:
composer require seekquarry/yioop
Demo: https://www.yioop.com/
Docs and downloads: https://www.seekquarry.com/r/PHP • u/ProjektGopher • 3h ago
News This Week in PHP Internals | Nov 26, 2026
youtu.bePreface: what follows is the word-for-word transcript of the spoken dialogue in the video, chapter by chapter with timestamps, for anyone who'd rather read than click through. If this digest is still too long for you, we recommend copying it into your LLM of choice and asking for a summary of our summary.
Cold Open (00:00)
Thirteen years ago this week, php.net launched the design you still see today, with a commit message that read "GO LIVE WITH NEW DESIGN. GO GO GO GO!" Every attempt to replace it since has stalled. Until, maybe, now.
Hello world, it's Thursday, November 26, 2026, and here's what happened This Week in PHP Internals. 19 stories this week, so let's get into it. But first,
This week's episode is sponsored by Artisan Build, which is us. If you've got a PHP project that needs senior developers, book a call at artisan.build/start, or send us a DM on any platform.
PHP.net Redesign (00:46)
This week's top story: php.net may get its first homepage redesign in 13 years. Matt Stauffer posted one from the PHP Ambassadors marketing group, as a pull request with a live preview. The goal is a homepage that's more welcoming to newcomers and shows what modern PHP offers. He opened it on November 20th, 13 years to the day after php.net announced its current design. That design spent about three years as an opt-in beta, and went live with a commit that read, "GO LIVE WITH NEW DESIGN. GO GO GO GO!"
There was no RFC. Matt says it came mainly out of discussions on the webmaster mailing list. Since then, proposals to rewrite or replace it in 2014 and 2019 went nowhere, and a 2020 pull request was closed as outdated. The homepage got a new hero section in 2022, but it's still mostly a news feed, and it still has no dark mode.
Back in 2019, Levi Morrison, who says he did the 2013 redesign, wrote: "If you think the current PHP website is old, out-dated, and bland, you must have not experienced the previous one." The release pages are where the design moved, with 8.5's coming out of a design contest last year. Matt's redesign builds on that page.
Links: The pull request (no merge before December 4) · Live preview
Redesign Feedback (02:18)
Most of the first replies were warm. Larry Garfield called it "orders of magnitude better than the current front page", though he wants more purple. Juliette Reinders Folmer misses the elePHPants and finds the look corporate, which Matt says is deliberate, to help make PHP's case in boardrooms. She also wants the footer's Donate button renamed, because, she wrote, "This is not charity. This is funding for business critical software." Kalle Sommer Nielsen wants the Twitter link back and an RFC, given the scale of the change. Matt pointed out that the 2013 redesign and the 8.5 release page both shipped without one, but if an RFC is the only way forward, that's what they'll do. Either way, there's no merge before December 4th.
I'd love it if you'd tell us in the comments what you do and don't like about this new proposed design, and what you may or may not miss from the current one. To weigh in where Matt is collecting feedback, the pull request and the list thread are linked below, with how to join the internals list, the RFC process and the PHP Community Discord.
Links: The pull request (no merge before December 4) · Matt Stauffer, "PHP.net homepage redesign — feedback requested" · Subscribe to the internals mailing list · How the RFC process works · The PHP Community Discord (a community server, not an official PHP one)
Docker ZTS (03:26)
Docker's official PHP 8.6 images shipped as thread-safe builds only, and the list wanted to know who asked for that. PHP comes in two builds. NTS, the non-thread-safe one, is PHP's default, and ZTS is the thread-safe one that FrankenPHP and the parallel extension need.
On Friday, Matteo Beccati, one of the 8.6 release managers, asked whether that had been an official request from the project. He wrote: "If not, I'm not sure it was appropriate to experiment like this on such a large user base, before publishing an RFC, discussing it and voting." Gina P. Banyard and Benjamin Außenhofer answered that these are Docker's official images, not the PHP project's, so no RFC applies. Marc Henderkes, who suggested the switch and wrote the change, said his question was never taken as official by Docker's maintainers. Matthew Sewell's reply was that Docker's maintainers made the change because they thought the PHP project had asked. He wrote: "I think this is a process question rather than a technical one."
On GitHub, Docker maintainer tianon said flipping the default back would be a breaking change, days after release. So on Wednesday he merged an nts variant instead, for 8.6 only. ZTS stays the default. Benjamin named the one change regular users may notice: on ZTS, max_execution_time counts wall-clock time instead of CPU time. That's an open issue on php-src.
Links: Matteo Beccati, "Docker images for 8.6 now default to ZTS" · docker-library/php: an 8.6 nts variant and zts aliases (merged Nov 25)
JSON Comments (05:12)
Your JSON config files may soon be allowed comments. Otar Chekurishvili's RFC adds two opt-in flags to json_decode and json_validate, one for comments and one for trailing commas. Without the flags, strict JSON stays the default. Voting opened on Wednesday, with a separate vote for each flag. The comments flag is at 11 to 0 so far. The trailing-commas flag is also at 11 to 0. Both votes close December 9th.
And personally? I love this proposal, and I think it's way overdue. I love how it's structured, and I'm very excited for it. Trailing commas in arrays and function signatures are literally my favorite PHP feature, so this is a step in the right direction.
Links: Opt-in JSON Comments and Trailing Commas RFC
Sunset PECL (06:01)
The vote to shut down PECL didn't open on Wednesday after all. James Titcumb's RFC would shut it down at the end of 2027. Tim Düsterhus says that's too fast. PHP 8.6 still has the --with-pear build flag, and the earliest it can go is PHP 8.7, next November, just one month before the shutdown. So he'd extend it through 2028. James isn't convinced. He says it means an extra year of manually removing vulnerable packages, and he'd leave that call to Derick Rethans, whose job that mostly is. Derick replied: "I think the idea would be to stick this in a repo, so anybody could then make a PR to hide these things. Shouldn't have to be just me." The RFC still says the end of 2027.
Links: Sunset PECL RFC
Working Groups (06:52)
Ben Ramsey's Working Groups RFC got stricter this week, and Tim Düsterhus thinks that made it worse. Larry Garfield's membership rules were merged in: a minimum number of members, and a process for removing them. Ben says the point of a working group is transparency, and that the final RFC from one is "primarily a formality". Then, this morning, Tim wrote: "Overall I feel that this update made the proposal even worse" His example is the infrastructure team, which he thinks is 2 people today. Under the new rules, a single resignation could dissolve it automatically, leaving no one authorized to maintain the servers, he says, or to hand them over. There's no vote yet.
Links: Working Groups RFC
Lazy Iterators (07:41)
A first-time poster wants PHP's iterators to get the array_* treatment. Paweł Wankiewicz proposes 11 iterator_* functions, like iterator_map, iterator_filter and iterator_reduce, that work through an iterator one item at a time, and fit straight into a pipe. Today, you'd call iterator_to_array first, which loads everything into memory. On 5 million lines of JSON, he measured 3.1 gigabytes that way, against 11 kilobytes for iterator_reduce. He also disclosed that he wrote the implementation with help from Claude, and that the design decisions are his.
Ilija Tovilo replied: "Small heads-up that this has been on my TODO list for the longest time. I was planning on collaborating with Tim Düsterhus on a similar proposal." The hard part, Ilija says, is speed compared to a plain loop. Paweł's own numbers have a filter, map and reduce chain 2.2 times slower than foreach with the JIT. He offered to collaborate, and Ilija granted him RFC karma either way.
I really like this one. It starts from a problem you can actually measure. Paweł volunteered how he used AI without anyone asking. Ilija pointed out it's been sort of planned for a while, and left the door open to working on it together. To me, this feels like the perfect example of how the list is meant to work. I'm super interested to see how this one progresses.
Links: Paweł Wankiewicz, "[Pre-RFC] Lazy iterator_* functions"
Deprecated Interfaces (09:12)
PHP's Deprecated attribute can't go on an interface today. Daniel Scherzer's new RFC allows it there, so implementing or extending one emits a deprecation. Larry Garfield called it "an obvious addition". At Tim Düsterhus's suggestion, instanceof checks and type declarations won't warn. The open question is a hierarchy. If a library deprecates its own interface because the parent it extends is deprecated, Tim would hide the parent's warning. Daniel thinks that might be a footgun, and has asked for other opinions.
Links: Deprecated interfaces RFC
Delayed Votes (09:51)
Two RFCs that announced votes this week are now waiting. Pratik Bhujel planned to open voting on Io\Terminal on Tuesday, then held off after one more review from Tim Düsterhus. Version 0.7 came the same day, spelling out $columns instead of $cols, and adding an EofException, so callers can handle the end of input separately.
And Ayoub Ezzini withdrew his array_partition vote for tomorrow. Tim pointed out that his last change needs a two-week cooldown, which would push the vote into the holidays, so it now opens after them.
Links: Io\Terminal RFC · array_partition() RFC
String Matching (10:28)
Str\Matcher has a vote date, and a naming question. Artem Ukrainskiy's version 0.5 targets PHP 8.7, keeps its names, and goes to a vote on January 11th, after the holidays. The same evening, Tim Düsterhus objected to the new Str namespace. It would be the first namespace for one of the scalar types, and he says that needs "strong justification", and a plan for the whole hierarchy. He also finds the class names awfully generic, and suggested StrSet or StrSetMatcher in the global namespace instead. Artem hasn't replied yet.
Links: Prepared Literal String Matching and Replacement RFC · Tim Düsterhus on the Str\ namespace
Under the Hood (11:09)
Three engine proposals moved this week. The proposal to share identical opcode arrays between cached scripts got its first answer, from Arnaud Le Blanc. It doesn't need an RFC, he says, and can be discussed in a pull request. But it breaks the assumption that the same opcodes mean the same function, and by the proposal's own security review, one tenant can break into another.
Matthieu Napoli measured Levi Morrison's alternative to a single binary for CLI and FPM, a shared library. Lambda cold starts improve just the same, but on x86-64 it ran up to 7.7% slower, unless it's built with -Bsymbolic, which needs bigger changes for distributions. So Matthieu still prefers the single binary.
And Tim Düsterhus reviewed Kévin Dunglas's request lifecycle hooks for worker-mode servers, asking what happens to an open php://input stream between requests.
Links: Arnaud Le Blanc on OPcache dedup · Single binary for CLI and FPM RFC · Request lifecycle hooks RFC
New Proposals (12:12)
Four new ideas arrived this week. This morning, Marc Henderkes proposed removing the mm session handler instead of making it thread-safe. None of the common distributions enable it, and he found no public mention of it since 2008. Hassan Ahmed wants PDO::FETCH_GROUP to let you choose the column it groups by, instead of always the first one.
Robert Chapin suggested a double question mark on parameter types, so a function could accept an unset variable without a warning. Tim Düsterhus says that's a linter's job. Larry Garfield replied: "We do not need language syntax to make bad code pretend to work."
And Gregory Magarshak proposed that PHP 9 only include .php and .phar files, and refuse to write them. Replies pointed out that template engines like Twig and Blade compile to PHP files, and Craig Francis pointed back to his is_literal RFC.
Links: Marc Henderkes on removing the mm session handler · Hassan Ahmed's PDO::FETCH_GROUP pull request · Robert Chapin, "Null Coalesce Handling Revised" · Gregory Magarshak, "Common-sense security hardening"
Quick Hits (13:15)
Quick hits. grapheme_str_pad is at 13 to 0, up from 6 last week, and its vote closes December 2nd.
Links: grapheme_str_pad() RFC
On PASSWORD_BCRYPT_WRAP, Jakub Zelenka wrote that PHP shouldn't create its own password hashing algorithm, and that, if anything, he'd support the simpler bcrypt-sha256.
Links: Jakub Zelenka on PASSWORD_BCRYPT_WRAP
Xavier Leune will switch his curl callback to a single URI, at Tim Düsterhus's suggestion, and Tim called gethostaddresses a good short-term fix.
Links: Vetting cURL connections RFC · Tim Düsterhus on gethostaddresses()
Máté Kocsis simplified query parameters, Larry Garfield ruled out NoDiscard for context managers, Juliette's b prefix deprecation found 2 uses in the top 10,000 packages, and Ignace Nyamagana Butera asked the CSV extension to throw on infinity and NaN.
Links: Query Parameter Manipulation Support RFC · Context Managers v2 RFC · PHP 8.7 deprecations: the b prefix · CSV extension RFC
TL;DR (14:10)
So that's the week. php.net has its first homepage redesign in 13 years up for feedback, with no merge before December 4th. Docker's PHP 8.6 images stay thread-safe by default, with an nts variant if you need it. JSON comments are 11 to 0 in voting, and the PECL shutdown vote didn't open, with the timeline still in question. Links below.
The PHP Foundation funds more than half of ongoing php-src commits, so if you use the language, maybe consider donating at opencollective.com/phpfoundation, or try guilting your employer into it.
If you found this useful, a like or a comment helps more people find it. And if you missed last week's episode, where PHP 8.6 came out alongside 7 critical security fixes, that's a good one to watch next. And if you'd like to work with us, book a call at artisan.build/start. We're Artisan Build. See you next week.
r/PHP • u/jgamboa-cl • 1d ago
Arco: an open-source CLI to deploy PHP to AWS Lambda Web Functions with FrankenPHP (MIT)
github.comHi 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 • u/OndrejCh • 14h ago
Intelephense vs. Intellisense
intelephense.comI've just found out Intellisense is an implementation of the code completion from Microsoft, NOT the general term - and I was using that way 🤦♂️
PHP has Intelephense. Am I getting it right?
r/PHP • u/Past-Paint87 • 11h ago
Discussion Googlebot caused 485k disk writes in one hour on my PHP site. Sessions and counters were the part I could cut
I'm building Rezervomat, an online booking system for small businesses, on top of the Osclass PHP core. On 24 November the hosting IO chart for the production site showed a peak of about 485k write operations in one hour. The access log had Googlebot crawling our documentation in 7 languages at roughly 1,500 requests an hour.
3 things were writing on every anonymous request. The core started a PHP session and stored a session file even for a cookie-less crawler request. Our own per-visit counters (page cache stats, rate limits, a crawler hit table) wrote to files or the database on every page view. And blog views were counted for bots too.
What I've changed: a cookie-less GET from a crawler user agent no longer gets a stored session. I added increment() to the object cache backends in the core, so counters live in APCu or memcache instead of files and the database, and page cache stats are appended in 5-minute slots instead of per request. The crawler hit table is gone completely.
I haven't confirmed how much of the remaining IO is MySQL temp tables on disk, and I only tested the increment path on APCu, not memcache. If the spikes come back I'll run the query log for one crawl hour.
For those of you who run PHP sites with a lot of bot traffic: do you skip sessions and counters for known crawlers by user agent, or let them through and filter later? I don't fully trust the user agent, so for the bots that matter I also check reverse DNS.
r/PHP • u/13heyitsme • 1d ago
Discussion Running PHPCompatibility inside WordPress without exec(): what I learned
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 • u/amitmerchant • 18h ago
Article What PHP’s session vulnerability teaches us about atomicity
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 • u/barel-barelon • 2d ago
News PHP Debugger - Agentic zero-overhead debugging
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 • u/No_Muffin464 • 1d ago
Laravel Safe Migrations v1.1: catch dangerous migrations before they hit production (updated with your feedback)
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 • u/lyrixx86 • 2d ago
php-wasm-builder 1.0: compile PHP to WebAssembly, with your extensions and your code, and run it in the browser
blog.lyrixx.infor/PHP • u/SadSpirit_ • 2d ago
el2sql: Translator from Symfony's ExpressionLanguage to SQL (Postgres dialect)
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 • u/IrisDigital • 2d ago
News KnpSnappy, laravel-snappy and phpwkhtmltopdf without the archived wkhtmltopdf: the same command line on a current Chromium
github.comwkhtmltopdf 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 • u/alexbabintsev • 3d ago
XMLReader::setSchema() takes almost two minutes on a 20 MB base64 element (quadratic in libxml2)
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
Phast: a drop-in Composer alternative or a "design & speed reference"?
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 • u/Far-Spare4238 • 2d ago
News Public beta for Pun which is ultrafast unified PHP toolchain.
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 • u/janedbal • 3d ago
⚡ Meet turbocov: a PHP code coverage engine with 400× less overhead than Xdebug
github.comCode 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-phpunitand 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 • u/sashalav • 5d ago
Ondrej's php repository move
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 updater/PHP • u/Late-Honeydew-9247 • 3d ago
Discussion I released MicroUnit 1.0, a zero-dependency testing framework. I'd like critical feedback on it.
MicroUnit is a PHP testing framework where a test is a closure with a name, and nothing gets installed besides MicroUnit itself:
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 • u/Tomas_Votruba • 3d ago
Bun for PHP - Pun - is coming, WDYT?
x.comJavascript 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?