Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 11c9c18

Browse files
committed
Merging develop to master in preparation for 1.8.0 release.
2 parents 2b33fcd + c0acf7a commit 11c9c18

22 files changed

+808
-429
lines changed

CHANGELOG.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,74 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5-
## 1.7.3 - TBD
5+
## 1.8.0 - 2018-06-27
66

77
### Added
88

9-
- Nothing.
9+
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) adds the following functions under the `Zend\Diactoros` namespace, each of
10+
which may be used to derive artifacts from SAPI supergloabls for the purposes
11+
of generating a `ServerRequest` instance:
12+
- `normalizeServer(array $server, callable $apacheRequestHeaderCallback = null) : array`
13+
(main purpose is to aggregate the `Authorization` header in the SAPI params
14+
when under Apache)
15+
- `marshalProtocolVersionFromSapi(array $server) : string`
16+
- `marshalMethodFromSapi(array $server) : string`
17+
- `marshalUriFromSapi(array $server, array $headers) : Uri`
18+
- `marshalHeadersFromSapi(array $server) : array`
19+
- `parseCookieHeader(string $header) : array`
20+
- `createUploadedFile(array $spec) : UploadedFile` (creates the instance from
21+
a normal `$_FILES` entry)
22+
- `normalizeUploadedFiles(array $files) : UploadedFileInterface[]` (traverses
23+
a potentially nested array of uploaded file instances and/or `$_FILES`
24+
entries, including those aggregated under mod_php, php-fpm, and php-cgi in
25+
order to create a flat array of `UploadedFileInterface` instances to use in a
26+
request)
1027

1128
### Changed
1229

1330
- Nothing.
1431

1532
### Deprecated
1633

17-
- Nothing.
34+
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) deprecates `ServerRequestFactory::normalizeServer()`; the method is
35+
no longer used internally, and users should instead use `Zend\Diactoros\normalizeServer()`,
36+
to which it proxies.
37+
38+
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) deprecates `ServerRequestFactory::marshalHeaders()`; the method is
39+
no longer used internally, and users should instead use `Zend\Diactoros\marshalHeadersFromSapi()`,
40+
to which it proxies.
41+
42+
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) deprecates `ServerRequestFactory::marshalUriFromServer()`; the method
43+
is no longer used internally. Users should use `marshalUriFromSapi()` instead.
44+
45+
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) deprecates `ServerRequestFactory::marshalRequestUri()`. the method is no longer
46+
used internally, and currently proxies to `marshalUriFromSapi()`, pulling the
47+
discovered path from the `Uri` instance returned by that function. Users
48+
should use `marshalUriFromSapi()` instead.
49+
50+
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) deprecates `ServerRequestFactory::marshalHostAndPortFromHeaders()`; the method
51+
is no longer used internally, and currently proxies to `marshalUriFromSapi()`,
52+
pulling the discovered host and port from the `Uri` instance returned by that
53+
function. Users should use `marshalUriFromSapi()` instead.
54+
55+
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) deprecates `ServerRequestFactory::getHeader()`; the method is no longer
56+
used internally. Users should copy and paste the functionality into their own
57+
applications if needed, or rely on headers from a fully-populated `Uri`
58+
instance instead.
59+
60+
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) deprecates `ServerRequestFactory::stripQueryString()`; the method is no longer
61+
used internally, and users can mimic the functionality via the expression
62+
`$path = explode('?', $path, 2)[0];`.
63+
64+
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) deprecates `ServerRequestFactory::normalizeFiles()`; the functionality
65+
is no longer used internally, and users can use `normalizeUploadedFiles()` as
66+
a replacement.
67+
68+
- [#303](https://github.com/zendframework/zend-diactoros/pull/303) deprecates `Zend\Diactoros\Response\EmitterInterface` and its various implementations. These are now provided via the
69+
[zendframework/zend-httphandlerrunner](https://docs.zendframework.com/zend-httphandlerrunner) package as 1:1 substitutions.
70+
71+
- [#303](https://github.com/zendframework/zend-diactoros/pull/303) deprecates the `Zend\Diactoros\Server` class. Users are directed to the `RequestHandlerRunner` class from the
72+
[zendframework/zend-httphandlerrunner](https://docs.zendframework.com/zend-httphandlerrunner) package as an alternative.
1873

1974
### Removed
2075

composer.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
},
1919
"extra": {
2020
"branch-alias": {
21-
"dev-master": "1.7.x-dev",
22-
"dev-develop": "1.8.x-dev",
21+
"dev-master": "1.8.x-dev",
22+
"dev-develop": "1.9.x-dev",
2323
"dev-release-2.0": "2.0.x-dev"
2424
}
2525
},
@@ -37,6 +37,16 @@
3737
"psr/http-message-implementation": "1.0"
3838
},
3939
"autoload": {
40+
"files": [
41+
"src/functions/create_uploaded_file.php",
42+
"src/functions/marshal_headers_from_sapi.php",
43+
"src/functions/marshal_method_from_sapi.php",
44+
"src/functions/marshal_protocol_version_from_sapi.php",
45+
"src/functions/marshal_uri_from_sapi.php",
46+
"src/functions/normalize_server.php",
47+
"src/functions/normalize_uploaded_files.php",
48+
"src/functions/parse_cookie_header.php"
49+
],
4050
"psr-4": {
4151
"Zend\\Diactoros\\": "src/"
4252
}

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/book/api.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,31 @@ $request = RequestFactory::fromGlobals(
128128
);
129129
```
130130

131+
### ServerRequestFactory helper functions
132+
133+
- Since 1.8.0
134+
135+
In order to create the various artifacts required by a `ServerRequest` instance,
136+
Diactoros also provides a number of functions under the `Zend\Diactoros`
137+
namespace for introspecting the SAPI `$_SERVER` parameters, headers, `$_FILES`,
138+
and even the `Cookie` header. These include:
139+
140+
- `Zend\Diactoros\normalizeServer(array $server, callable $apacheRequestHeaderCallback = null) : array`
141+
(its main purpose is to aggregate the `Authorization` header in the SAPI params
142+
when under Apache)
143+
- `Zend\Diactoros\marshalProtocolVersionFromSapi(array $server) : string`
144+
- `Zend\Diactoros\marshalMethodFromSapi(array $server) : string`
145+
- `Zend\Diactoros\marshalUriFromSapi(array $server, array $headers) : Uri`
146+
- `Zend\Diactoros\marshalHeadersFromSapi(array $server) : array`
147+
- `Zend\Diactoros\parseCookieHeader(string $header) : array`
148+
- `Zend\Diactoros\createUploadedFile(array $spec) : UploadedFile` (creates the
149+
instance from a normal `$_FILES` entry)
150+
- `Zend\Diactoros\normalizeUploadedFiles(array $files) : UploadedFileInterface[]`
151+
(traverses a potentially nested array of uploaded file instances and/or
152+
`$_FILES` entries, including those aggregated under mod_php, php-fpm, and
153+
php-cgi in order to create a flat array of `UploadedFileInterface` instances
154+
to use in a request)
155+
131156
## URI
132157

133158
`Zend\Diactoros\Uri` is an implementation of
@@ -177,6 +202,13 @@ In most cases, you will only use the methods defined in the `UploadedFileInterfa
177202

178203
## Server
179204

205+
> ### Deprecated
206+
>
207+
> The class `Zend\Diactoros\Server` is deprecated as of the 1.8.0 release. We
208+
> recommend using the class `Zend\HttpHandlerRunner\RequestHandlerRunner` via
209+
> the package [zendframework/zend-httphandlerrunner](https://docs.zendframework.com/zend-httphandlerrunner)
210+
> instead.
211+
180212
`Zend\Diactoros\Server` represents a server capable of executing a callback. It has four methods:
181213

182214
```php

doc/book/emitting-responses.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Emitting responses
22

3+
> ## Deprecated
4+
>
5+
> Emitters are deprecated from Diactoros starting with version 1.8.0. The
6+
> functionality is now available for any PSR-7 implementation via the package
7+
> [zendframework/zend-httphandlerrunner](https://docs.zendframework.com/zend-httphandlerrunner).
8+
> We suggest using that functionality instead.
9+
310
If you are using a non-SAPI PHP implementation and wish to use the `Server` class, or if you do not
411
want to use the `Server` implementation but want to emit a response, this package provides an
512
interface, `Zend\Diactoros\Response\EmitterInterface`, defining a method `emit()` for emitting the

doc/book/overview.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ well as a "server" implementation similar to [node's http.Server](http://nodejs.
66

77
This package exists:
88

9-
- to provide a proof-of-concept of the accepted PSR HTTP message interfaces with relation to
10-
server-side applications.
11-
- to provide a node-like paradigm for PHP front controllers.
9+
- to provide an implementation of [PSR-7 HTTP message interfaces](https://www.php-fig.org/psr/psr-7)
10+
- with relation to server-side applications.
1211
- to provide a common methodology for marshaling a request from the server environment.

doc/book/usage.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ $response = $response
118118

119119
### "Serving" an application
120120

121+
> ### Deprecated
122+
>
123+
> The class `Zend\Diactoros\Server` is deprecated as of the 1.8.0 release. We
124+
> recommend using the class `Zend\HttpHandlerRunner\RequestHandlerRunner` via
125+
> the package [zendframework/zend-httphandlerrunner](https://docs.zendframework.com/zend-httphandlerrunner)
126+
> instead.
127+
121128
`Zend\Diactoros\Server` mimics a portion of the API of node's `http.Server` class. It invokes a
122129
callback, passing it an `ServerRequest`, an `Response`, and optionally a callback to use for
123130
incomplete/unhandled requests.

src/Response/EmitterInterface.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?php
22
/**
3-
* Zend Framework (http://framework.zend.com/)
4-
*
5-
* @see http://github.com/zendframework/zend-diactoros for the canonical source repository
6-
* @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2015-2018 Zend Technologies USA Inc. (https://www.zend.com)
75
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
86
*/
97

108
namespace Zend\Diactoros\Response;
119

1210
use Psr\Http\Message\ResponseInterface;
1311

12+
/**
13+
* @deprecated since 1.8.0. The package zendframework/zend-httphandlerrunner
14+
* now provides this functionality.
15+
*/
1416
interface EmitterInterface
1517
{
1618
/**

src/Response/SapiEmitter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<?php
22
/**
33
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4-
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
4+
* @copyright Copyright (c) 2015-2018 Zend Technologies USA Inc. (http://www.zend.com)
55
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
66
*/
77

88
namespace Zend\Diactoros\Response;
99

1010
use Psr\Http\Message\ResponseInterface;
1111

12+
/**
13+
* @deprecated since 1.8.0. The package zendframework/zend-httphandlerrunner
14+
* now provides this functionality.
15+
*/
1216
class SapiEmitter implements EmitterInterface
1317
{
1418
use SapiEmitterTrait;

src/Response/SapiEmitterTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4-
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
4+
* @copyright Copyright (c) 2015-2018 Zend Technologies USA Inc. (http://www.zend.com)
55
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
66
*/
77

@@ -16,6 +16,10 @@
1616
use function str_replace;
1717
use function ucwords;
1818

19+
/**
20+
* @deprecated since 1.8.0. The package zendframework/zend-httphandlerrunner
21+
* now provides this functionality.
22+
*/
1923
trait SapiEmitterTrait
2024
{
2125
/**

0 commit comments

Comments
 (0)