All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Fixed an issue with the dependencies in the
composer.json
files.
The library was rewriten from scratch around the PSR-15, PSR-7 and PSR-17 specifications.
-
All parameters of
::add()
and::before()
are obligatory. -
The
$baseDirectory
passed to the constructor must be an absolute path in relation to the file system, not just te doc root. -
Now all controllers receive two parameters: an instance of
Psr\Http\Message\ServerRequestInterface
andPsr\Http\Server\RequestHandlerInterface
respectively. -
::setNamespace()
renamed to::setDefaultNamespace()
.
-
::set404()
-
:passParametersAsArray()
-
::header404()
-
::parameter()
-
::setExceptionHandler()
-
::setNotFoundHandler()
- Routes were being attached to all HTTP methods instead of only the specidied ones.
- Files with extension longer than 3 characters were not being recognized as files.
Router
was generating error when faced with a empty path.
- The
Router::namespace()
method was using the "namespace" reserved word. Method replaced withRouter::setNamespace()
.
- Trying to set up routers for options and patch methods were generating error.
- Tidying up the documentation and some grammar errors.
- An error was occurring when omitting the first parameter of the of methods
::add()
and::before()
. - Only the first capture group was beign passed as a parameter to the callback.
-
Now
::add
and::before
accept file paths as callback, the file will be required if it exists and an exception will be thrown if it doesn't. -
Added the method
::passParametersAsArray()
. It changes how capture groups are passed to the callbacks.By default the capture groups in the regex patterns are passed to the callbacks as individual parameters, if
::passParametersAsArray(true)
is called then the capture groups will be passed in single parameter as an array. -
Added the
::parameter()
method to retrieve captured groups.
Request::getRoute()
andRequest::$route
renamed toRequest::getUri()
andRequest::$uri
respectively.- URIs no longer come with trailing slashes, as to avoid adding a
/?
at the end of the regex patterns.
- The ability to inform the base directory in the Router's constructor.
Just tidying up the documentation and some grammar errors.
Route::setNamespace($namespace)
Route::getUrl()
Route::getPath()
Route::getBaseHref()
Router::namespace($namespace)
Router::request
propriety.- Added support for before route middlewares.
Router::before($methods = '*', $patterns, $callback)
. Accept the same parameters as ::add() .
- Support for the head, patch and options http methods added.
Router::options()
shorthand.Router::patch()
shorthand.
-
Route::add has been overloaded, not only the $methods parameter accepts a ''*'' to represent all http methods, but it is now optional.
-
Request logic has been moved to a new separated class: Request.
-
Now the library also considers the x-http-method-override header to determine the http method used.
Now the router may call non-static methods by instantiating objects A bug fixed: ::namespace() may be used to set the defaultnamespace for functions/methods.
A bug fixed: Router::getPath() used to come with the query string attatched.