Latest release: v0.2

HTTP

Content

Curl

There is a prepared simple cURL client in this package.

You have to register it at first.

extensions:
    curl: Contributte\Http\DI\CurlExtension
1
2

Extension registers by automatic Contributte\Http\Curl\CurlClient as a service.

SAPI

Every modern PHP application needs sometimes to run a few console commands. Let's say sending newsletter campaigns. There is a tiny problem, there is no request/URL in console/SAPI (Server API) mode. Don't worry, just use our fake request - SapiRequestExtension.

The easiest way is to register extension without any parameters.

extensions:
    sapi: Contributte\Http\DI\SapiRequestExtension
1
2

Alternatively, you can pass directly URL address.

extensions:
    sapi: Contributte\Http\DI\SapiRequestExtension(https://contributte.org)
1
2

List of all options:

sapi:
    url: https://contributte.org
    # other params
    query: NULL
    post: NULL
    files: NULL
    cookies: NULL
    headers: NULL
    method: NULL
    remoteAddress: NULL
    remoteHost: NULL
    rawBodyCallback: NULL
1
2
3
4
5
6
7
8
9
10
11
12

Basic Authentication

extensions:
    auth: Contributte\Http\DI\BasicAuthExtension
1
2

You have to enable this extension by yourself. It's disabled by default.

auth:
    enabled: true/false
    title: My security zone
    users:
      username1:
        password: password1
        unsecured: true
      username2:
        password: $2y$10$p.U5q.BuQp02srggig.VDOqj5m7pE1rCwKavVQ3S2TrqWlkqu3qlC
        unsecured: false # secured by default
      username3:
        password: $2y$10$bgievYVQMzsRn5Ysup.NKOVUk66aitAniAmts2EJAa91eqkAhohvC
1
2
3
4
5
6
7
8
9
10
11
12

Useful classes

Url

Few methods added:

$url->appendPath($path)

use Contributte\Http\Url;

$url = new Url('https://github.com');

$url->appendPath('foo');
# https://github.com/foo

$url->appendPath('bar');
# https://github.com/foobar
1
2
3
4
5
6
7
8
9