r/PHP • • 19h ago

Article Laravel Rust is Here

Thumbnail laravel.com
68 Upvotes

r/PHP • • 2h ago

Video Laravel Rust beta: I read the benchmark methodology. The 18x is real, but most of it is just Rust

Thumbnail reddit.com
0 Upvotes

Laravel Rust went into beta on December 1. I went through the announcement, docs and benchmark post, and a few things stood out:

- Laravel Rust did 1,774 req/s vs 97 for Laravel PHP. But Rocket, a plain Rust framework, did 1,623 on the same test.

- The test was a simple read-only app with a 200-row dataset, using each framework's best 10-second window.

- At a steady 50 req/s, latency was close (62 ms vs 78 ms median). The big difference was RAM (16 MB vs 134 MB) and CPU.

- Cold builds on Laravel Cloud: about 3 min vs 27 s.

- What I like most: column types, input authorization and N+1 queries are all checked at compile time.

I made a short 90-second video summarising this (disclosure: it's mine):

Curious what people here think. Would you try it on a real project before 1.0, or wait?

Sources:

https://laravel.com/blog/introducing-laravel-for-rust

https://laravel.com/blog/laravel-rust-benchmark


r/PHP • • 8m ago

The cost of Rust

0 Upvotes

I know Rust pretty well. I did a partial-port, partial-rewrite of a big PHP project into Rust by hand. I've ported two more big systems for Rust using LLMs — one, a toy port of Psalm, and the other a port (playground here) of an 300k-line OCaml typechecker to Rust, which we use in CI at $company.

In all the production uses, the equation was:

benefit = production_savings - development_cost

production_savings = frequency_of_use * cpu_seconds_saved
development_cost = initial_port_cost + frequency_of_updates * seconds_waiting_for_rustc

cpu_seconds_saved: The ported projects were not typical of PHP workloads. They were all massively-CPU-bound, never waiting on a database or memcache, with high frequency use and provably-massive improvements in cpu_seconds_save per execution.

initial_port_cost is undoubtedly cheaper now with LLMs, but not free. Rewriting a large project in Rust by hand used to cost an expensive man-year. Today, porting a 300k-line typechecker cost in the mid-thousands of dollars, token-wise. That port relied on the upstream project's extremely comprehensive acceptance tests.

cpu_seconds_saved is the most important thing to determine before any Rust port. Unless your PHP site is very unusual, it's usually not going to be the biggest deal in the lifetime of any given request.

seconds_waiting_for_rustc we don't run rustc as part of any production deployment for our 15-million-LOC Hack codebase. It makes programs fast, but it is not fast. If your PHP project is > 100KLOC, prepare for a bit of pain.

I think it's really important to remember that your customers do not care about Rust or PHP. They just want to buy some shit on your site, or see what their local team is doing, or whatever. Rust is almost certainly overkill for that, unless you're serving millions of requests a day.


r/PHP • • 4h ago

Agent Skills in PHP: On-Demand Skills for Neuron AI Agents

0 Upvotes

Alessandro, a friend of Neuron AI gifted the community with this amazing package. After a but of work together I decided to host it under the offical Neuron github organization.

I think it's the better implementation across the agentic frameworks in any stack. It allows you to store skills in different storage layers not only the filesystem, such as a database. You can even implement your custom storage like S3 for example just implementing the package interface.

This is amazing because it fits web application archtiectures where you could need to store skills in the way your application wants to offer this feature to the users or for your own convenience. With this abstraction your agent doesn't care where skills physically are.

This is what PHP needs I think. Thank you Alessandro.

https://www.neuron-ai.dev/blog/agent-skills-in-php-on-demand-skills-for-neuron-ai-agents/


r/PHP • • 1h ago

Laravel's move into Rust got me thinking...

19 Upvotes

It reminded me of all the times Taylor and some of his most vocal supporters (especially those who work with him) mocked developers who advocated for stricter code and better coding practices within Laravel. And what do they do now? They embrace one of the strictest programming languages out there. Oh, the irony.

I'm not denying Rust's performance advantages, but I find it hard to believe that performance alone was the driving force behind this decision, especially considering the needs of most web applications.

To me, this looks more like a strategic business pivot aimed at expanding Laravel Cloud's market share and establishing a stronger source of recurring revenue.

After all, deploying a PHP-based Laravel application is incredibly easy these days. You can deploy it on cheap shared hosting, a $5 VPS, a traditional LAMP stack, a Docker container, or virtually any hosting provider that supports PHP. The ecosystem is mature, affordable, widely available, and doesn't tie you to any specific infrastructure provider.

For many small to medium-sized projects, Laravel Cloud offers convenience rather than solving an actual infrastructure problem. With Laravel Rust, however, they have an opportunity to capture a larger share of the hosting market. Many developers coming from PHP who are unfamiliar with deploying Rust applications may naturally gravitate toward Laravel Cloud. From a business perspective, it makes perfect sense.

They've also assured everyone that they won't abandon the PHP version, but I'm highly skeptical of that promise. I wouldn't be surprised if, a few years down the road, the PHP version gradually gets sidelined and eventually abandoned, followed by Taylor's loyal followers gaslighting anyone who reminds them of what was originally promised.

I just hope they don't bring the same culture of framework lock-in to the Rust ecosystem, where otherwise generic libraries gradually become framework-specific packages. (Hey, Spatie, I haven't forgotten what you did with your `data-transfer-object` package.)


r/PHP • • 6h ago

Article Laravel Rust vs PHP: is PHP the bottleneck?

Thumbnail rapira.rs
88 Upvotes

Follow-up to this thread, same setup (1 vCPU per container, Chirper traffic mix). This time the ramp goes up to 5k RPS instead of 2k.

In the original comparison Laravel ran on FrankenPHP and Symfony on Swoole, so the frameworks and the app servers changed at the same time. We added both frameworks on one common base, Rapira. That lets us compare the frameworks on the same app server, and then the same frameworks on different app servers and on Rust.

  • On the same app server, Laravel tops out at about 190 RPS and Symfony at about 2,900 RPS. The bottleneck is the framework and its abstractions, not PHP.
  • Above 2k RPS both Symfony setups beat Laravel Rust: 3,430 (Swoole) and 2,913 (Rapira) RPS vs 2,638.
  • Caddy in front of laravel-rust on 1 vCPU cost 27% of its throughput.

Takeaways

  1. Profile the framework before rewriting in another language. On this API PHP was not the bottleneck. Switching the app server mostly cut memory and errors under load, not RPS.
  2. Fit the data layer to the endpoint: fewer queries and no full model hydration where you don't need it.
  3. Compare runtimes on tail latency, errors under overload and memory, not on a single RPS number.

r/PHP • • 30m ago

Article Two Telegram packages for PHP: a grammY-style bot framework, and a "WhatsApp Web"-style client for your own account

1 Upvotes

Hi r/PHP! I've been building an ecosystem of packages for PAM, a persistent PHP runtime I work on, and just released two for Telegram. Both are Apache-2.0 and on Packagist. I'd love feedback on the API design.

1. `pushinbr/pam-telegram`: a bot framework

It's inspired by grammY and has zero Composer dependencies. It covers commands, filter queries (`message:photo`), middleware, sessions, multi-step scenes, inline keyboards, uploads, long polling and webhooks.

```php

$bot = new Bot(getenv('TELEGRAM_BOT_TOKEN'));

$bot->command('balance', fn (Context $ctx) => $ctx->reply('Your balance: $150.00', [

'reply_markup' => InlineKeyboard::make()->text('Refresh', 'balance:refresh'),

]));

$bot->callbackQuery('balance:refresh', function (Context $ctx): void {

$ctx->answer('Updated');

$ctx->edit('Your balance: $151.00');

});

$bot->run(); // long polling: no public URL, idle bot uses no CPU

```

Scenes handle conversations like "How much? → To whom? → Confirm", with state kept in the session, so they survive restarts.

It runs best on PAM, where the process stays alive and sessions live in memory. It also works on PHP-FPM, Laravel, Symfony or a plain script, with cURL or a stream fallback.

- GitHub: https://github.com/push-in/pam-telegram

2. `pushinbr/pam-telegram-web`: your own account, like a WhatsApp Web client

This one is for when you need to act as yourself, not as a bot. It drives Telegram Web in headless Chrome over the DevTools Protocol. You don't need an `api_id`, Node.js or Puppeteer.

```php

$client = new Client();

$client->onQrCode(fn ($e) => print $e->terminal()); // scan the QR right in your terminal

$client->onPasswordRequired(fn () => $client->submitPassword(readPassword()));

$client->onReady(fn ($e) => print "Connected as {$e->me?->name()}\n");

$client->onMessage(function ($e) {

if ($e->message->text === 'ping') {

$e->message->reply('pong');

}

});

$client->run();

```

You get chats, history, sending, live message events, and `invoke()` for any Telegram API method through the web client's own connection. The session is saved, so you only scan the QR once.

To be upfront: it's unofficial and depends on Telegram Web, so it can break when they change the site. It's meant for automating your own account, not for bulk messaging. Telegram bans spam accounts, and the README says so.

- GitHub: https://github.com/push-in/pam-telegram-web

Which one should I use?

- Building something for other people to talk to: use the bot.

- Automating your own account (reading a channel that has no bot, replying as you): use the web client.

Both READMEs have a 5-minute quick start. Questions, criticism and PRs are welcome, especially on the scene API and the event model. Thanks!


r/PHP • • 15h ago

Laravel Rust vs Symfony PHP: results from the same benchmark workload

Thumbnail x.com
32 Upvotes