Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
104 lines (76 sloc) 2.21 KB

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

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

Alternatively, you can pass directly URL address.

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

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

Basic Authentication

extensions:
    auth: Contributte\Http\DI\BasicAuthExtension

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

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
You can’t perform that action at this time.