1. Go to this page and download the library: Download weew/http library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
weew / http example snippets
$response = new HttpResponse();
$response->send();
$response = new HttpResponse();
$response->setContent('<h1>Hello World!</h1>');
$response->send();
$response = new HttpResponse(HttpStatusCode::UNAUTHORIZED);
// or
$response = new HttpResponse(401);
$response->send();
$response = new HttpResponse();
$response->getHeaders()->set('foo', 'bar');
$response->send();
$response = new HttpResponse();
$response->getQueuedCookies()->add(new Cookie('foo', 'bar'));
$response->send();
$response = new HtmlResponse();
$response->setHtmlContent('<h1>Hello World!</h1>');
$response->send();
$response = new JsonResponse();
$response->getData()->set('Hello', 'World!');
$response->send();
$response = new BasicAuthResponse('Please login');
$response->send();
$request = new HttpRequest(
HttpRequestMethod::POST,
new Url('http://example.com')
);
$request->setContent('foo=bar');
$request = new HttpRequest();
$request->getUrl()->getQuery()->set('foo', 'bar');
echo $request->getUrl()->getQuery();
// foo=bar