webclient/ext-cookie

Cookies extension for PSR-18 HTTP client

v1.0.1 2020-11-04 09:57 UTC

This package is auto-updated.

Last update: 2021-05-04 11:22:55 UTC


README

Latest Stable Version Total Downloads License PHP

webclient/ext-cookie

Cookie extension for PSR-18 HTTP client.

Install

Install this package and your favorite psr-18 implementation.

composer require webclient/ext-cookie:^1.0

Using

<?php

use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Webclient\Extension\Cookie\Client;
use Webclient\Extension\Cookie\Cookie\Storage;

/** 
 * @var ClientInterface $client Your PSR-18 HTTP Client
 * @var Storage $storage Cookies storage. You may extends this class for implements your storage
 */
$http = new Client($client, $storage);

/** @var RequestInterface $request */
$response = $http->sendRequest($request);

Provided cookies stores

  • \Webclient\Extension\Cookie\Cookie\ArrayStorage - Cookies stored in memory.
  • \Webclient\Extension\Cookie\Cookie\NetscapeCookieFile - Cookies stored in a file (format).