🔥 CodeIgniter
Intermediate
What is the HTTP Client in CodeIgniter 4?
Answer
CodeIgniter 4 includes a built-in HTTP Client (based on cURL) for making outgoing HTTP requests to external APIs. Get it: $client = service("curlrequest"). Make a GET request: $response = $client->get("https://api.example.com/users"). POST with JSON: $client->post($url, ["json" => $data]). With headers: $client->get($url, ["headers" => ["Authorization" => "Bearer " . $token]]). Access response: $response->getStatusCode(), $response->getBody(), $response->getJSON(). Options: timeout, connect_timeout, allow_redirects, verify (SSL). CI4's HTTP client is simpler than Guzzle but sufficient for most API calls. For complex scenarios (connection pooling, async requests), use Guzzle via Composer.