I’ve just released Slim Framework 1.6.0 into the stable branch. This is a major release and includes a brand new framework architecture based upon the Rack Protocol.
New Rack Architecture
The Slim Framework 1.6.0 implements a derivative of the Rack Protocol. Upon instantiation, the Slim application will extrapolate a set of variables from the
$_SERVER superglobal into an instance of Slim_Environment. The Slim application uses these environment variables to route the current HTTP request and return an appropriate HTTP response.
New application middleware
A Slim application may now use application-wide middleware to inspect or modify the application environment, request, or response before and/or after the Slim application is run. Middleware is a very powerful addition to the Slim Framework opening up many new possibilities for your application.
Improved request interface
The Slim_Http_Request object has an improved interface making it easier for developers to inspect the current HTTP request.
Improved response interface
The Slim_Http_Response object has an improved interface making it easier for developers to prepare the HTTP response.
Improved session handling
Unlike previous versions, Slim Framework 1.6.0 will not start a native PHP session on its own. If you need a native PHP session, you should configure and start a native PHP session on your own before instantiating a Slim application. Many application developers found Slim’s earlier session implementation too presumptuous; the new implementation in 1.6.0 allows more configuration with less assumptions.
The Slim_Middleware_SessionCookie middleware may be used to persist signed, encrypted session data to an HTTP cookie just like earlier versions of the Slim Framework.
Improved cookie handling
Slim Framework 1.6.0 no longer uses PHP’s native
setcookie() method. Instead, Slim Framework 1.6.0 constructs and stores cookies in the response object’s header. This allows the application developer to inspect and tweak cookie data in application middleware before the HTTP response is returned to the client.
Slim Framework 1.6.0 allows more flexible logging with custom log writers that direct logged data to the appropriate output destination (e.g. file, database, Twitter, or remote web service).
Improved test coverage
Like every new release, Slim Framework 1.6.0 includes improved PHPUnit test coverage and updated phpDocumentor API documentation.
Other miscellaneous additions
Slim Framework 1.6.0 includes many more smaller additions, including:
- Support for the
- New application
expires()method for improved HTTP caching
- Improved compatibility with web servers using gzip compression
- Compatibility with the Composer package manager
How To Upgrade
Slim Framework 1.6.0 should be a seamless upgrade from earlier versions. The only potential issues while upgrading older applications are with sessions and logging.
As mentioned above, Slim Framework 1.6.0 will not start a native PHP session on its own. If your current application relies on a native PHP session, you’ll want to configure and start a PHP session before you instantiate your application.
If you prefer to continue persisting session data into a signed, encrypted HTTP cookie, you will want to add the Slim_Middleware_SessionCookie middleware to your application.
Slim Framework 1.6.0 provides an updated logging implementation with custom log writers. You may need to update your application’s logger so that it continues sending logged data to the same location. By default, Slim Framework 1.6.0 will send logged messages to STDERR.