From 9d519abd2c3cbd5c445ee7200e5d135a6cd6e439 Mon Sep 17 00:00:00 2001 From: Trevor Suarez Date: Sun, 20 Jul 2014 20:33:02 -0400 Subject: [PATCH 1/8] Initial changelog document --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..2baa9626 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,37 @@ +# CHANGELOG + +## 2.1.0 + +### Features + +- New exception and helper methods to help control the dispatch flow +- New `abort()` method to allow stopping the routing process and returning a response code +- Routes are now instances of a new `Route` class, instead of just being a set of meta properties and a callback +- Routes are now stored in a `RouteCollection` class, which extends the `DataCollection` class +- New `keys()` and `clear()` methods for the `DataCollection` class +- Added the capability of reverse routing! +- Now allowing for route callbacks to change the response object by returning a new ApiResponse instance +- New "slug" type for route param matching +- New `isEmpty()` and `cloneEmpty()` methods for the `DataCollection` class +- The `$matched` route callback parameter is now an instance of a `RouteCollection`, instead of just an integer +- Route callbacks are now passed the Klein instance for easier closure/class-scope use +- Regular expression routing is now more accurate and will match more special characters in a similar way to Sinatra +- Routes are now built with a dependency injected `AbstractRouteFactory` instance, allowing the building of routes to be customized more easily +- New `options()` and `head()` alias methods for matching OPTIONS and HEAD requests respectively +- The `Response` class has been abstracted into an `AbstractResponse` and a separate `Response` class for cleaner 3rd-party extension +- New "after dispatch" callbacks can be registered for firing a series of callbacks after the dispatch loop has completed +- New `patch()` alias method for matching PATCH requests +- New HTTP error handling via exceptions and callback registration for a more direct (and less magical) API for controlling HTTP errors +- The `escape()` method in the `ServiceProvider` class now allows for the passing of entity escaping flags +- 100% Code Coverage + +### Bug fixes + +- The README document has been updated to fix a few typos and inconsistencies +- Route params are now properly URL decoded +- 404/405 routes now properly set the appropriate status code automatically +- Silencing the locked response exceptions as the behavior is designed to be transparent/automatic +- Allow route callables to be an array suitable for `call_user_func()` callable behavior +- More proper handling for 404's that also call the 404 error handlers +- The `file()` and `json()` methods in the `Response` class no longer override system-configured time processing limits +- Now checking if the output buffer is open before attempting to close it From 434b236826fb6c7db8ba0bea514d8a918795c9c8 Mon Sep 17 00:00:00 2001 From: Trevor Suarez Date: Sun, 20 Jul 2014 20:34:03 -0400 Subject: [PATCH 2/8] Initial Klein Upgrading Guide template --- UPGRADING.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 UPGRADING.md diff --git a/UPGRADING.md b/UPGRADING.md new file mode 100644 index 00000000..d8fac48f --- /dev/null +++ b/UPGRADING.md @@ -0,0 +1,7 @@ +# Klein Upgrade Guide + +## 2.0.x to 2.1.0 + +### Deprecations + +### Interface Changes From bc41b09188e17178ef7a09dde2d141ea7290791c Mon Sep 17 00:00:00 2001 From: Trevor Suarez Date: Mon, 21 Jul 2014 09:06:24 -0400 Subject: [PATCH 3/8] Bumping version in the install instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 38341d39..230c4bd6 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ ## Composer Installation 1. Get [Composer](http://getcomposer.org/) -2. Require Klein with `php composer.phar require klein/klein v2.0.x` +2. Require Klein with `php composer.phar require klein/klein v2.1.x` 3. Install dependencies with `php composer.phar install` ## Example From d8f0a93b823883053c628ebdb6848ad86a2f388d Mon Sep 17 00:00:00 2001 From: Trevor Suarez Date: Fri, 7 Nov 2014 00:50:56 -0500 Subject: [PATCH 4/8] Added new features and bug-fixes to the CHANGELOG --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2baa9626..daef44d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,10 @@ - New `patch()` alias method for matching PATCH requests - New HTTP error handling via exceptions and callback registration for a more direct (and less magical) API for controlling HTTP errors - The `escape()` method in the `ServiceProvider` class now allows for the passing of entity escaping flags +- Route regular expressions are now validated and provide helpful errors upon a validation failure +- Routes can now contain an empty string path +- The composer autoloader is now compatible with the PSR-4 standard. +- Regular expression compilation performance has been improved - 100% Code Coverage ### Bug fixes @@ -35,3 +39,6 @@ - More proper handling for 404's that also call the 404 error handlers - The `file()` and `json()` methods in the `Response` class no longer override system-configured time processing limits - Now checking if the output buffer is open before attempting to close it +- The methods matched counter (`$methods_matched`) is now much more accurate, not counting methods that shouldn't have been considered matches +- Various PHPdoc inaccuracies and inconsistencies have been fixed +- Regular expressions are now quoted during compilation in a much safer manner From d58ff6d6c1f4568dd27b80bf64f23495af92d3e6 Mon Sep 17 00:00:00 2001 From: Trevor Suarez Date: Fri, 7 Nov 2014 00:51:50 -0500 Subject: [PATCH 5/8] Ironed out some details in the UPGRADING doc --- UPGRADING.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/UPGRADING.md b/UPGRADING.md index d8fac48f..be307d03 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -4,4 +4,27 @@ ### Deprecations +- Handling 404 and 405 errors with a specially registered route callback is now deprecated. It's now suggested to use Klein's new `onHttpError()` method instead. +- Autoloading the library with Composer no longer utilizes the PSR-0 spec. The composer autoloader now uses PSR-4. + ### Interface Changes + +- Some of the route callback params have changed. This will effect any route definitions with callbacks using the more advanced parameters. + - The old params were (in order): + - `Request $request` + - `Response $response` + - `Service $service` + - `App $app` + - `int $matched` + - `array $methods_matched` + - The new params are (in order): + - `Request $request` + - `Response $response` + - `Service $service` + - `App $app` + - `Klein $klein` + - `RouteCollection $matched` + - `array $methods_matched` +- Non-match routes (routes that are wildcard and shouldn't consider as "matches") will no longer be considered as part of the "methods matched" array, since they aren't supposed to be matches in the first place + - This may have implications for users that have created "match-all" OPTIONS method routes, as the OPTIONS method will no longer be considered a match. + - If you'd like to conserve the old match behavior, you can simply mark the route as one that should be counted as a match with `$route->setCountMatch(true)` From 5a0117aa262591cebf0f9c5e67b4f9fd8afc110e Mon Sep 17 00:00:00 2001 From: Trevor Suarez Date: Fri, 7 Nov 2014 02:15:39 -0500 Subject: [PATCH 6/8] Updating the installation instructions to no longer specify the version, so that the user always gets the latest stable --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 230c4bd6..26882dd5 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,8 @@ ## Composer Installation 1. Get [Composer](http://getcomposer.org/) -2. Require Klein with `php composer.phar require klein/klein v2.1.x` -3. Install dependencies with `php composer.phar install` +2. Require Klein with `php composer.phar require klein/klein` +3. Add the following to your application's main PHP file: `require 'vendor/autoload.php';` ## Example From d5810fc5400add235e2bbbbf95ec4b1c57bebd1f Mon Sep 17 00:00:00 2001 From: Trevor Suarez Date: Fri, 7 Nov 2014 02:20:38 -0500 Subject: [PATCH 7/8] PHPdoc mention? --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index daef44d3..4387c9dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,3 +42,4 @@ - The methods matched counter (`$methods_matched`) is now much more accurate, not counting methods that shouldn't have been considered matches - Various PHPdoc inaccuracies and inconsistencies have been fixed - Regular expressions are now quoted during compilation in a much safer manner +- The PHPdoc tags have been updated to use the more modern syntax From cb99d02c41076fb369929454ee30032f021e70ab Mon Sep 17 00:00:00 2001 From: Trevor Suarez Date: Fri, 7 Nov 2014 02:23:48 -0500 Subject: [PATCH 8/8] Project description update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26882dd5..08ea6081 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/chriso/klein.php.png?branch=master)](https://travis-ci.org/chriso/klein.php) -**klein.php** is a lightning fast router for PHP 5.3+ +**klein.php** is a fast & flexible router for PHP 5.3+ * Flexible regular expression routing (inspired by [Sinatra](http://www.sinatrarb.com/)) * A set of [boilerplate methods](#api) for rapidly building web apps