Now that the day job is finally slowing down a bit, I’ve been back at work on the Slim Framework. Here are several new features and changes coming in the next stable release — currently available in the develop branch to help you start updating your applications.
- HTTP headers that contain the HTTP_ prefix now retain the HTTP_ prefix in the Environment object.
- HTTP headers are parsed from the Environment object on instantiation and made available in the Request’s public
- Cookies are parsed from the Environment object on instantiation and made available in the Request’s public
- The Request’s public
cookiesproperties use the new
If you use custom middleware to update the Request object’s headers or cookies, you must now do so on the Request object’s
headers properties rather than on the Environment object.
The following Request object methods will be deprecated in the next major point release:
- HTTP headers are now set on the Response’s public
- HTTP cookies are now set on the Response’s public
- The Response’s public
cookiesproperties uses the \Slim\Helper\Set interface.
getStatus()methods instead of
- Use the public
headersproperty directly instead of
- Use the
setBody()methods instead of
- Use the
getLength()method instead of
- Iterate the
cookiesproperties instead of the Response object itself.
- With the new \Slim\Helper\Set interface, Response object cookies are not serialized into raw HTTP headers until the very end of the Slim application lifecycle (after the final middleware is run, immediately before the HTTP response is returned to the client). This allows custom middleware to use the simpler \Slim\Helper\Set interface to manipulate Response cookies rather than mess with raw HTTP
The following Response object methods and interfaces will be deprecated in the next major point release:
The next stable release will introduce the \Slim\Helper\Set interface. This interface will be used by many of the collections in a Slim application: cookies, headers, etc. This interface will help unify and simplify many of Slim’s methods and interfaces. The \Slim\Helper\Set interface is:
This interface implements \ArrayAccess, \Countable, and \IteratorAggregate.
All of the to-be-deprecated methods shown above will continue to work until the next major point release.
If you have any questions, send me a tweet at @slimphp or post a question on the Slim Framework forum.