~thirdplace/http

http utilities
feat: add post() function
initial commit

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~thirdplace/http
read/write
git@git.sr.ht:~thirdplace/http

You can also use your local clone with git send-email.

#Http

Utilities related to http.

#Tutorial

Install with composer:

composer require thirdplace/http:dev-main

Install manually:

wget https://git.sr.ht/~thirdplace/http/blob/main/http.php

Example usage:

<?php

try {
    $result = Thirdplace\get('https://example.com', ['timeout' => 3]);
} catch (\RuntimeException $e) {
    exit("hmm\n");
}

if ($result['code'] === 200) {
    print $result['body'];
} else {
    print "oh\n";
}

#Explanation

Returns an associative array with code and body. Uses curl. Throws \RuntimeException on curl failure.

#How-to

#Reference

function get(string $url, array $config = []): array