-
-
Save m6w6/e3de44ef1a8260ecebde to your computer and use it in GitHub Desktop.
<?php | |
require "vendor/autoload.php"; | |
require "vendor/rdlowrey/after/lib/functions.php"; | |
$promises = (new Artax\Client)->requestMulti(array_fill(0, 100, "http://www.google.com")); | |
$responses = After\all($promises)->wait(); | |
foreach ($responses as $response) { | |
printf( | |
"HTTP/%s %d %s\n", | |
$response->getProtocol(), | |
$response->getStatus(), | |
$response->getReason() | |
); | |
} |
After a composer update, I still get the same result?
installed:
bagder/ca-bundle dev-master origin/master
daverandom/addr v0.2.4 Asynchronous DNS resolver using Alert
daverandom/libdns v0.2.1 DNS protocol implementation written in pure PHP
rdlowrey/acesync v0.2.4 Non-blocking TCP socket connection/encryption tools
rdlowrey/after v0.2.1 Simple PHP concurrency primitives
rdlowrey/alert v0.10.2 Event loops and stream IO reactors for non-blocking PHP applications
█ mike@smugmug:~/src/artax.git<git=master...origin/master>$ php google100.php
HTTP/1.1 200 OK
Yeah those are still the old version numbers. I'm something of a composer noob so I can't say exactly what the problem is, but re-cloning the repo and installing via composer fixed it for me. Your test script just worked fine on my end. I'm putting the commands here so you can copy/paste for convenience:
git clone https://github.com/rdlowrey/Artax.git
cd Artax
composer.phar install
One other note: the functions.php include in line 4 of your original snippet is no longer necessary as I fixed the relevant composer file to add it to the autoloader as well.
Please let me know if it still gives you problems.
Yes, so I've broken the underlying
After\all()
dependency function. I'll fix it today. In the meantime you can manually workaround it for benchmarking purposes by doing the things thatAfter\all()
is supposed to hide from the user like so:The by-ref
$count
variable will increment in the$onComplete
callback and stop the event loop when the last response resolves.