TGViewer
PWRTelegram API channel PWRTelegram API channel @pwrtelegram · 719 subscribers
Post #514 726

Forwarded from Daniil Gentili's news channel (Daniil Gentili)

I'm very happy to announce the first release of https://github.com/danog/php-tokio: you can now use any async Rust library from PHP!

It's fully integrated with revolt: this allows full compatibility with amphp, PSL and reactphp, and with any Rust library powered by tokio.rs.

Here's an example from the repo, using the async Rust reqwest library to make asynchronous HTTP requests from PHP:

<?php

use Reqwest\Client;

use function Amp\async;
use function Amp\Future\await;

require 'vendor/autoload.php';

Client::init();

function test(int $delay): void {
$url = "https://httpbin.org/delay/$delay";
$t = time();
echo "Making async reqwest to $url that will return after $delay seconds...".PHP_EOL;
Client::get($url);
$t = time() - $t;
echo "Got response from $url after ~".$t." seconds!".PHP_EOL;
};

$futures = [];
$futures []= async(test(...), 5);
$futures []= async(test(...), 5);
$futures []= async(test(...), 5);

await($futures);

I'm really excited for the potential usecases of php-tokio, and its implications for the PHP async ecosystem.

I've created this library because I'm building an async MongoDB client for PHP (https://github.com/Nicelocal/mongo-php-async-driver), and realized that using the official rust mongodb library directly from PHP would be way easier (and faster!) than writing a MongoDB client in pure PHP :)


P.S. Here's the link to the hackernews thread I created for the occasion :)
https://news.ycombinator.com/item?id=37285471
GitHub GitHub - danog/php-tokio: Use any async Rust library from PHP! Use any async Rust library from PHP! Contribute to danog/php-tokio development by creating an account on GitHub.
More from @pwrtelegram
  1. May 11, 2025And then, a long overdue post about my Autonomous System (AS198747), and an over more over…
  2. May 11, 2025The first series of posts I'll be adding here will be some technical deep dives into the p…
  3. May 11, 2025Happy to announce I've launched a blog, where I'll be posting news about all my different…
  4. Aug 25, 2024#FreeDurov.
  5. May 30, 2024MadelineProto was updated! MadelineProto 8.1.0 introduces an official Grafana dashboard fo…
  6. Apr 27, 2024MadelineProto was updated! 8.0.0 is the first stable release of MadelineProto v8! For the…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →