2017 © Pedro Peláez
 

library http

Value Objects to abstract http messages

image

innmind/http

Value Objects to abstract http messages

  • Saturday, April 28, 2018
  • by Baptouuuu
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,489 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 21 Versions
  • 12 % Grown

The README.md

Http

Build Status codecov Type Coverage, (*1)

Immutable value objects and interfaces to abstract http messages., (*2)

Important: you must use vimeo/psalm to make sure you use this library correctly., (*3)

Build a ServerRequest

use Innmind\Http\Factory\ServerRequestFactory;
use Innmind\TimeContinuum\Clock;

$request = ServerRequestFactory::native(Clock::live())();

Send a Response

use Innmind\Http\{
    Response,
    Response\StatusCode,
    Response\Sender\Native,
    ProtocolVersion,
    Headers,
    Header,
    Header\ContentType,
};
use Innmind\Filesystem\File\Content;
use Innmind\TimeContinuum\Clock;

$response = Response::of(
    StatusCode::ok,
    ProtocolVersion::v11,
    Headers::of(
        ContentType::of('application', 'json'),
    ),
    Content::ofString('{"some": "data"}'),
);

Native::of(Clock::live()))($response);

will build the following message:, (*4)

HTTP/1.1 200 OK
Date: Wed, 04 May 2016 14:24:14 +0000
Content-Type : application/json

{"some": "data"}

Build a multipart Request

use Innmind\Http\{
    Request,
    Method,
    Content\Multipart,
    Header\ContentType\Boundary,
    Headers,
    ProtocolVersion,
};
use Innmind\Filesystem\{
    File,
    File\Content,
};
use Innmind\Url\Url;

$boundary = Boundary::uuid();
$request = Request::of(
    Url::of('http://some-server.com/')
    Method::post,
    ProtocolVersion::v11,
    Headers::of($boundary->toHeader()),
    Multipart::boundary($boundary)
        ->with('some[key]', 'some value')
        ->withFile('some[file]', File::named(
            'whatever.txt',
            Content::ofString(' can be any file content'),
        )),
);

The Versions

19/03 2017

2.0.2

2.0.2.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

The Development Requires

http value object

19/03 2017

2.0.1

2.0.1.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

The Development Requires

http value object

14/02 2017

2.0.0

2.0.0.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

The Development Requires

http value object

01/02 2017

1.5.0

1.5.0.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

The Development Requires

http value object

17/12 2016

1.4.1

1.4.1.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

The Development Requires

http value object

24/09 2016

1.4.0

1.4.0.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

The Development Requires

http value object

18/09 2016

1.3.0

1.3.0.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

The Development Requires

http value object

30/06 2016

1.2.3

1.2.3.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

http value object

25/06 2016

1.2.2

1.2.2.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

http value object

25/06 2016

1.2.1

1.2.1.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

http value object

25/06 2016

1.2.0

1.2.0.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

http value object

04/05 2016

1.1.0

1.1.0.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

http value object

04/05 2016

1.0.0

1.0.0.0 http://github.com/Innmind/Http

Value Objects to abstract http messages

  Sources   Download

MIT

The Requires

 

http value object