r/PHP • • 2d ago

Weekly help thread

3 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 • • 6d 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 • • 22h ago

News PHP Debugger - Agentic zero-overhead debugging

46 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 • • 4h 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

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
9 Upvotes

r/PHP • • 1h 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

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

9 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 • • 23h 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 • • 1d 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 elementXMLReader + setSchema()DOMDocument::schemaValidate()
5 MB6.3 s0.01 s
10 MB26 s0.02 s
20 MB109 s0.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 • • 19h ago

What do you think the new Laravel announcement will be?

Thumbnail reddit.com
0 Upvotes

r/PHP • • 18h 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 • • 23h 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 • • 2d ago

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

Thumbnail github.com
1 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):

DriverTimeOverhead
no coverage18.7 s–
turbocov19.3 s+3 %
PCOV36.7 s+96 %
Xdebug250 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 • • 3d ago

Ondrej's php repository move

140 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?


r/PHP • • 2d ago

Building static websites with Sculpin with Oliver Davies · Zoom · Luma

Thumbnail luma.com
0 Upvotes

r/PHP • • 3d ago

Docker images for 8.6 now default to ZTS

Thumbnail externals.io
59 Upvotes

r/PHP • • 4d ago

Is this a dream? The new proposed homepage is gorgeous

Thumbnail github.com
211 Upvotes

It does look ai generated though. But it’s much, much better than what we have now. Definitely an upgrade. Hope it’s approved.


r/PHP • • 3d ago

Upwind research: the two new critical PHP CVEs, which versions are affected, and how to tell which of your servers are actually exposed

0 Upvotes

Hi r/PHP, this is the research team at Upwind (cloud security). We’ve been helping teams triage the two critical PHP CVEs this week and wanted to share what we’ve learned, since most scanners flag every server running an affected version whether it’s reachable or not.

What we’d patch first:

  • Internet-facing php-fpm with file uploads enabled
  • Old VMs still running mod_php. They get forgotten because they’re not in the container pipeline
  • Long-running CLI and queue workers. They keep the old binary loaded until restarted

One trap we keep seeing: the fixed package is installed, but the php-fpm workers were never restarted, so the vulnerable code is still in memory. Treat “patched but not restarted” as still vulnerable.

Affected versions, fixed releases and mitigations if you can’t patch today are all here:
https://www.upwind.io/blog/php-critical-vulnerabilities-affected-versions-and-mitigations

Happy to answer questions in the comments. And if you’re triaging this differently (patch everything flat vs. by exposure), we’d like to hear how.


r/PHP • • 4d ago

News National Security Agency struggled with PHP Upgrade in outage

Thumbnail cbsnews.com
125 Upvotes

Honestly hearing that the big fancy digital National Security Agency with thousands of staff and contractors cannot upgrade PHP without literally shuttering the front gate of Fort Meade makes me feel a lot better about pulling everything off on a shoestring and we should all take this as a feel good story. Maybe they should turn in some zero days they've been hiding and save themselves some hassle later as well lol

CBS NEWS:::

The National Security Agency's network outage Tuesday has been linked to an urgent patching of vulnerabilities in PHP, the programming language that powers the majority of all websites, multiple sources told CBS News. 

The NSA's internal network, which is used to store and share classified information, went offline Tuesday, prompting the agency to stagger arrival times for some personnel at its headquarters at Fort Meade, Maryland.

Artificial intelligence helped uncover a pair of critical security vulnerabilities, triggering a global scramble last month to update software used by much of the internet, including the NSA. 

The flaws, collectively known as PHP2Shell, affect PHP, which is a programming language used by roughly 70% of websites. The race to patch vulnerable systems may help explain some of the recent technology disruptions. 

The PHP2Shell threat was so serious that the FBI, NSA and CISA issued urgent warnings just under a month ago, on Oct. 21, directing organizations to immediately patch vulnerable systems. The three agencies also advised those unable to install the fixes to take affected systems offline altogether until they could be secured. 

Speaking on Fox Business Tuesday, Director of National Intelligence Jay Clayton directly linked the NSA's classified network outage to urgent software updates following the discovery of critical vulnerabilities in PHP.

"If you go back about 10 days ago, we had what was labeled as PHP, an update to a web interface system," Clayton said. "And the patching that has gone on following that has caused some of these systems to not come back up when you patch them as expected. That is what has happened at the NSA today."

According to two sources familiar with the system, NSA Net as of right now is back up and running. Nonetheless, staggered arrival is continuing as fears persist that the system might not be able to handle everyone signing on at the same time. There is no word yet on how long the agency will continue the staggered arrival schedule, known as "Code Gray."

NSA maintains that mission critical information sharing has not been impacted, while it asks personnel to delay nonessential tasks, according to sources. The NSA said Tuesday the agency had experienced a "temporary degradation during scheduled routine maintenance," adding that its mission/critical capabilities were still fully operational. The NSA is responsible for collecting and analyzing foreign signals intelligence, identifying and countering cyber threats and protecting U.S. government communications. 

The agency has not yet responded to a CBS News request for an update on Wednesday.

One U.S. intelligence official described the broader challenge of updating infrastructure that was originally designed for an earlier internet era. The volume and speed of changes can overwhelm aging equipment. The official's assessment reflects a growing concern among intelligence and Homeland Security officials that modern technology is advancing faster than the systems that support it.

Speaking about PHP vulnerabilities, Clayton also pointed to the growing role of AI in speeding up both those kinds of discoveries and the pressure to respond. He described PHP as a "legacy vulnerability" that has been successfully patched across systems globally, adding, "This type of identification of vulnerabilities and patching goes on all the time."
......


r/PHP • • 3d ago

Share Private Client Demos With Six-Digit Email Codes

Thumbnail instawormhole.com
0 Upvotes