{"id":13610203,"url":"https://github.com/danog/php-tokio","last_synced_at":"2025-04-12T23:39:38.191Z","repository":{"id":190990825,"uuid":"683731985","full_name":"danog/php-tokio","owner":"danog","description":"Use any async Rust library from PHP!","archived":false,"fork":false,"pushed_at":"2024-03-31T16:20:24.000Z","size":56,"stargazers_count":320,"open_issues_count":0,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-12T15:58:49.438Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-08-27T14:27:52.000Z","updated_at":"2024-09-23T06:28:59.000Z","dependencies_parsed_at":"2024-03-31T17:27:56.440Z","dependency_job_id":"ba319ab1-8b78-4065-81cb-cf669e0e301c","html_url":"https://github.com/danog/php-tokio","commit_stats":null,"previous_names":["danog/php-tokio"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Fphp-tokio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Fphp-tokio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Fphp-tokio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Fphp-tokio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danog","download_url":"https://codeload.github.com/danog/php-tokio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647255,"owners_count":21139081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T19:01:42.404Z","updated_at":"2025-04-12T23:39:38.167Z","avatar_url":"https://github.com/danog.png","language":"Rust","funding_links":[],"categories":["Integration \u0026 adapters","Rust","Async \u0026 Runtime"],"sub_categories":["Tunnel"],"readme":"# php-tokio - Use any async Rust library from PHP!\n\nCreated by Daniil Gentili ([@danog](https://github.com/danog)).  \n\nThis library allows you to use any async rust library from PHP, asynchronously.  \n\nIt's fully integrated with [revolt](https://revolt.run): this allows full compatibility with [amphp](https://amphp.org), [PSL](https://github.com/azjezz/psl) and reactphp.  \n\n## Example\n\nHere's an example, using the async Rust [reqwest](https://docs.rs/reqwest/latest/reqwest/) library to make asynchronous HTTP requests from PHP:\n\n```php\n\u003c?php\n\nuse Reqwest\\Client;\n\nuse function Amp\\async;\nuse function Amp\\Future\\await;\n\nrequire 'vendor/autoload.php';\n\nClient::init();\n\nfunction test(int $delay): void {\n    $url = \"https://httpbin.org/delay/$delay\";\n    $t = time();\n    echo \"Making async reqwest to $url that will return after $delay seconds...\".PHP_EOL;\n    Client::get($url);\n    $t = time() - $t;\n    echo \"Got response from $url after ~\".$t.\" seconds!\".PHP_EOL;\n};\n\n$futures = [];\n$futures []= async(test(...), 5);\n$futures []= async(test(...), 5);\n$futures []= async(test(...), 5);\n\nawait($futures);\n```\n\nUsage:\n\n```bash\ncd examples/reqwest \u0026\u0026 \\\n    cargo build \u0026\u0026 \\\n    composer update \u0026\u0026 \\\n    php -d extension=../../target/debug/libexample_reqwest.so test.php\n```\n\nResult:\n\n```\nMaking async reqwest to https://httpbin.org/delay/5 that will return after 5 seconds...\nMaking async reqwest to https://httpbin.org/delay/5 that will return after 5 seconds...\nMaking async reqwest to https://httpbin.org/delay/5 that will return after 5 seconds...\nGot response from https://httpbin.org/delay/5 after ~5 seconds!\nGot response from https://httpbin.org/delay/5 after ~5 seconds!\nGot response from https://httpbin.org/delay/5 after ~5 seconds!\n```\n\nSee the [source code](https://github.com/danog/php-tokio/tree/master/examples/reqwest) of the example for more info on how it works!\n\n## Built with php-tokio\n\nHere's a list of async PHP extensions built with php-tokio ([add yours by editing this file!](https://github.com/danog/php-tokio/edit/master/README.md)):\n\n- [nicelocal/mongo-php-async-driver](https://github.com/Nicelocal/mongo-php-async-driver) - An async MongoDB PHP extension","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanog%2Fphp-tokio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanog%2Fphp-tokio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanog%2Fphp-tokio/lists"}