Migration to Version 2
If you are only using the PSR-7 implementations (e.g.,
ServerRequest, etc.), migrating to v2 can be done by updating your
laminas/laminas-diactoros constraint in your
composer.json. You have two
options for doing so:
- Adopt the v2 release specifically:
$ composer require "laminas/laminas-diactoros:^2.0"
Update your constraint to allow either version:
Edit the constraint in your
"laminas/laminas-diactoros": "^1.8.6 || ^2.0"
Update your dependencies:
$ composer update
The first approach may fail if libraries you depend on specifically require a version 1 release. The second approach may leave you on a version 1 release in situations where other libraries you depend on require version 1.
In all cases, if you are only using the PSR-7 implementations and/or the
ServerRequestFactory::fromGlobals() functionality, upgrading to version 2 will
pose no backwards compatibility issues.
Laminas\Diactoros\RequestTraitnow raises an
withMethod()for invalid HTTP method values.
Laminas\Diactoros\Serializer\Request::toString()no longer raises an
UnexpectedValueExceptiondue to an unexpected HTTP method; this is due to the fact that the HTTP method value can no longer be set to an invalid value.
Several features were removed for version 2. These include removal of the
Emitter functionality, the
Server implementation, and a number of methods on
Laminas\Diactoros\Response\EmitterInterface and all emitter implementations were
removed from laminas-diactoros. They are now available in the
In most cases, these can be replaced by changing the namespace of imported
Laminas\Diactoros\Server class has been removed. We recommend using the
RequestHandlerRunner class from laminas/laminas-httphandlerrunner
to provide these capabilities instead. Usage is similar, but the
RequestHandlerRunner provides better error handling, and integration with
A number of public static methods have been removed from
ServerRequestFactory. The following table details the methods removed, and
replacements you may use if you still require the functionality.
|Method Removed||Replacement functionality|