amphp/artax
Deprecated (unmaintained) async HTTP/1.1 client for PHP built on Amp. Implements HTTP over raw TCP sockets (no ext/curl), with keep-alive pooling, redirects, gzip decoding, streaming bodies, TLS, cookies, and proxy support. Use amphp/http-client instead.
Pros:
ext/curl Dependency: Useful in environments where curl is unavailable or restricted (e.g., Docker containers with minimal PHP builds).Cons:
amphp/http-client, which may introduce breaking changes or require migration effort.Swoole or ReactPHP) can host Amp, but requires explicit setup (e.g., Amp\Loop). Conflicts may arise with Laravel’s native HTTP client (Illuminate\Http\Client).php artisan queue:work) could leverage Artax for concurrent HTTP tasks, but may introduce race conditions without proper synchronization.GuzzleHttp\Promise). Easier to integrate but lacks Artax’s low-level control.Symfony\Component\HttpClient (built on ReactPHP). More actively maintained than Artax.http-client: Direct replacement with improved features (e.g., HTTP/2 support).amphp/http-client may be necessary, requiring refactoring of request/response handling.Why Artax Over Alternatives?
curl, HTTP/1.1 strict compliance) that justify using a deprecated library?amphp/http-client or Symfony HTTP Client meet the same needs with lower risk?Async Strategy
Maintenance Plan
amphp/http-client or another client if needed?Performance Impact
Failure Modes
Core Stack:
ext/curl needed.amphp/amp (v2.x): Core concurrency framework.amphp/socket: For TCP connections.amphp/byte-stream: For stream handling.amphp/file for file uploads/downloads.Illuminate\Http\Client (Guzzle-based) in the same request pipeline.Async Runtime:
swoole.event_loop to use Amp’s loop.use Amp\Loop;
use Swoole\EventLoop;
EventLoop::set(Loop::get());
amp/react package).Assessment Phase:
Pilot Integration:
class ArtaxClient
{
private $client;
public function __construct()
{
$this->client = new \Artax\Client();
}
public function get(string $url): \Artax\Response
{
return $this->client->request('GET', $url);
}
}
$this->app->singleton(ArtaxClient::class, function ($app) {
return new ArtaxClient();
});
Full Adoption:
use Amp\Loop;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
class FetchDataJob implements ShouldQueue
{
use Queueable;
public function handle(ArtaxClient $client)
{
$response = $client->get('https://api.example.com/data');
// Process response...
}
}
Fallback Mechanism:
try {
$response = $client->get($url);
} catch (\Exception $e) {
$fallback = new \GuzzleHttp\Client();
$response = $fallback->get($url);
}
Storage::disk()).Response object differs from Laravel’s Illuminate\Http\Response or Guzzle’s `Psr7\ResponseHow can I help you explore Laravel packages today?