simple-php-router

Simple, fast and yet powerful PHP router that is easy to get integrated and in any project. Heavily inspired by the way Laravel handles routing, with both simplicity and expand-ability in mind.

Downloads
140.9K
Stars
646
Committers
13
simple-php-router - 5.0.0.2

Published by skipperbent over 1 year ago

  • Fixed PHP8 deprecation warnings.
  • Fixed Github Workflows.
  • Updated PHPUnit
simple-php-router - 5.0.0.1

Published by skipperbent over 1 year ago

  • Fixed deprecated return-type for InputItem
simple-php-router - 5.0.0.0

Published by skipperbent over 1 year ago

  • Feature: dynamic domains
  • Bugfix: url-encoding
  • Other bugfixes + improvements
  • Updated to PHP version 7.4
simple-php-router - Version 4.3.7.2

Published by skipperbent over 3 years ago

  • Fixed issue causing group prefix to trigger on paths without "/" (issue #573 - thanks @Venloress).
simple-php-router - Version 4.3.7.1

Published by skipperbent over 3 years ago

  • Updated documentation.
simple-php-router - Version 4.3.7.0

Published by skipperbent over 3 years ago

  • Added new Group attribute mergeExceptionHandlers to prevent router from merging inherited exception-handlers (issue: #573).
  • RouteGroup: Added setMergeExceptionHandlers and getMergeExceptionHandlers methods.
  • IRouteGroup: Added setMergeExceptionHandlers and getMergeExceptionHandlers method.
  • Updated documentation to reflect changes.
  • Added unit-tests.
simple-php-router - Version 4.3.6.2

Published by skipperbent over 3 years ago

  • Updated documentation.
simple-php-router - Version 4.3.6.1

Published by skipperbent over 3 years ago

  • Fixed DebugHandler::fireEvent not providing correct arguments when calling fireEvents.
  • Fixed custom regex setMatch not setting parsed parameters correctly (issue: #566).
  • Added unit-tests for catching issue in the future.
  • Added php-stan typehints.
simple-php-router - Version 4.3.6.0

Published by skipperbent over 3 years ago

  • Fixed issue causing default-namespace to add duplicate namespace when using type-hints (issue: #561).
  • Fixed phpstan issues.
  • Tests: Fixed TestRouter not resetting namespace upon reset.
  • Tests: Added NSController (namespace controller) class.
  • Tests: added test for class hint + default namespace case.
  • Composer: added phpstan support + configuration.
simple-php-router - Version 4.3.5.0

Published by skipperbent over 3 years ago

  • Feature: Added support for InputHandler::exists to check array of indexes exists.
  • Simplified RouteController and RouteResource by moving common group-match code to parent method.
  • Updated documentation to reflect changes.
simple-php-router - Version 4.3.4.2

Published by skipperbent over 3 years ago

  • Issue #551: Fixed issue with SimpleRouter::error not firing within group.
  • Fixed variable incorrect variable reference in InputItem class.
  • Added new Router::addExceptionHandler method.
  • Added parameter types in Url class.
  • Fixed phpdoc parameter-type for Request::getHeader.
simple-php-router - Version 4.3.4.1

Published by skipperbent over 3 years ago

  • Issue #551: fixed issue causing SimpleRouter::error helper not to work when used within a group.
  • Tests: added unit test for nested group calls to SimpleRouter::error.
simple-php-router - Version 4.3.4.0

Published by skipperbent over 3 years ago

  • InputItem can now be used like array (for example: input()->post('items')[0]) if value is array.
  • Changed default-value parameter for get, post and file methods to allow for mixed object as return-type (input()->post('form', new InputItem('post')).
  • Fixed InputItem->__toString() to correctly parse null default-value.
  • Tests: changed parameter in call_user_func_array for PHP 8 compatibility in unit-tests.
simple-php-router - Version 4.3.3.0

Published by skipperbent over 3 years ago

  • [FEATURE] Namespace overwrite now works globally. Service will append to any existing namespace whereas \Service will overwrite it.
  • [FEATURE] Exception handlers are now rendered in reverse order from newest to oldest. This allows for exceptions to be handled from parent exceptions which were otherwise ignored.
  • Fixed incorrect return type for InputFile::getError to correct nullable int.
  • Added return type to all, match, controller and resource in SimpleRouter class.
  • Fixed incorrect return-type usage of parse_str function in Url::setQueryString method.
  • Fixed incorrect expected value in array_flip function in Url::removeParams method.
  • Tests: added namespace overwrite group unit-tests.
simple-php-router - Version 4.3.2.3

Published by skipperbent over 3 years ago

Changelog

  • Fixed deprecated notice when using class type hinting (issue: #538).
  • Minor optimisations.
simple-php-router - Version 4.3.2.2

Published by skipperbent over 3 years ago

Changelog

  • Removed ?string return type from IResourceController as the return type can be mixed.
simple-php-router - Version 4.3.2.1

Published by skipperbent over 3 years ago

Changelog

  • Feature: Added optional includeParams parameter to Url::getRelativeUrl and Url::getAbsoluteUrl methods.
  • Issue: Fixed issue with BaseCsrfVerifier matching urls against urls with parameters.
simple-php-router - Version 4.3.2.0

Published by skipperbent over 3 years ago

Changelog

  • Feature: Added IP-access restrictions with credits to @DeveloperMarius.
  • Feature: Added new include property to BaseCsrfVerifier for routes that should be allowed when used in conjunction with the exclude property and url-ranges (like /admin/*).
  • Feature: Added https scheme support to Request::setUri (used when calling $request->getUrl()->getAbsoluteUrl().
  • Feature: Added isSubRoute event parameter for EVENT_ADD_ROUTE.
  • Feature: Added method IGroupRoute::prependPrefix.
  • Feature: Added custom base path example to the documentation.
  • Tests: Added BaseCsrfVerifier unit-tests.
  • Tests: Added custom base path event unit-tests.
  • Updated documentation with changes & updates.
simple-php-router - Version 4.3.1.0

Published by skipperbent over 3 years ago

Release notes

  • Router now uses IClassLoader to load class methods. If you use a custom class-loader, make sure that you implement the new loadClassMethod from the IClassLoader interface.

Changelog

  • Feature: Added class + method loading to IClassLoader.
  • Feature: Added support for parameters in group prefix.
  • Issue: Fixed PHP 8 compatibility issues with call_user_func_array in ClassLoader.
  • Issue: Fixed parameters from parent-routes not correctly passed to child routes.
  • Issue: Fixed possible error causing parameters not to be set properly when using some groups.
  • Issue: Fixed InputHandler::find and InputHandler::value failing when using array in methods parameter.
  • Issue: Fixed csrf-token postback not being recognized.
  • Cleanup: Removed unused import reference.
  • Tests: Added more partial-group tests.
  • Tests: Added deep route-parameters pass unit-test
  • Tests: Added InputHandler::find tests.
  • Updated documentation to reflect changes.
simple-php-router - Version 4.3.0.0

Published by skipperbent over 3 years ago

Breaking changes

THIS UPDATE CONTAINS BREAKING CHANGES!
PLEASE READ THE NOTES CAREFULLY BEFORE UPDATING ANY LIVE ENVIRONMENT.

  • php-di no longer integrated by default
    php-di integration is still possible, however a custom class-loader is now used to create integrations with frameworks of choice. See the "Class Loader" section in the documentation for more information and examples on how to migrate your existing php-di integration.

  • Return type for input() helper
    The input helper function and associated method InputHandler::value has been fixed to return the raw value as originally intended. As a result IInputItem is no longer returned when calling input('name'). All references to input('my-input')->getValue() should therefore be changed to input('my-input'). The IInputItem object can still be accessed by using input()->find('my-input') instead.

Changelog

  • Feature: Added better ip-parsing when calling Request::getIp() and added new optional $safeMode parameter.
  • Feature: Added Request::getContentType for content-type header-parsing.
  • Feature: Added better support for nested file/arrays in InputHandler.
  • Feature: Added support for GitHub actions thanks to @DeveloperMarius
  • Feature #438: Added support for mixed value types in InputItem.
  • Feature #477: Removed php-di
  • Feature #452: Added option to disable multi-route rendering by calling Router::setRenderMultipleRoutes($bool)).
  • Feature: Added alias for easier access SimpleRouter::enableMultiRouteRendering($bool).
  • Feature #491: Added support for class hinting on routes.
  • Feature #453: Added option to get/set the filterEmptyParams option on IRoute classes.
  • Feature #446 #507: Default-namespace optimisations.
  • Feature: Added new Request::getFirstHeader method that returns the first header found from array list- used to simplify the code.
  • Feature: Added new InputHandler::getValueFromArray method that loops through input-items to ensure that value is always returned when calling the InputHandler->value() method.
  • Feature: Added new ClassNotFoundHttpException thrown when class is not found.
  • Feature: Added support for objects like array etc as default-value. Value is now less strict and accept mixed objects.
  • Feature: Added $_FILE support for Request::all method.
  • Feature: Parameters are by default now using regex [\w\-]+ (supports dashes) to avoid any confusion.
  • Feature #461: input()->all() will now always return keys defined. If the key doesn't exists the value will be set to null.
  • Feature: Added Request::isPostBack helper method that returns true if request-method is of type that could contain data in body.
  • Feature: Optimized namespace handling. When namespaces starts with \ they will always overwrite the default-namespace.
  • Issue #446: Router::setDefaultNamespace() no longer has to be set in the beginning of routes.php.
  • Issue #468: Fixed group not matching domain when using domain with no parameters.
  • Issue #439: Fixed multiple request-type on same routes.
  • Issue #456: Fixed issue with child groups not loading when using partialGroups.
  • Issue #437: Fixed CSRF-token returning null on first refresh after cookies are removed.
  • Issue #503: Fixed issue with custom-regex maching both host-name and url.
  • Issue #448: Fixed findRoute not working in BootManager.
  • Issue #450: Fixed issue with cookie-expiration timestamp for 32-bit PHP versions.
  • Issue #449: Fix 'must be an instance of Closure, array given' error when $closure is a object method.
  • Issue: Fixed calling SimpleRouter::getUrl with array as parameters option would throw an error.
  • Issue: Fixed SimpleRouter::getUrl having wrong nullable return type.
  • Issue: Fixed typo in getIp method when server is using the x-forwarded-for header.
  • Issue: Fixed possible bug causing InputHandler not to get the correct request-method.
  • Simplified constructor in Request class.
  • ClassNotFoundHttpException is now thrown when class/method is not found (backwards compatible).
  • Removed all references to php-di from composer + code.
  • Added tryParse argument to the Request->getHeader method. When enabled the method will try to parse headers from both server and client-side (enabled by default).
  • Simplified references that checks for both variants of header (http/non http).
  • Simplified getIp method of the Request-class.
  • Optimized InputHandler to better support for nested values.
  • Removed unused exception from PHP-docs.
  • Fixed types not same as declared.
  • Removed unnecessary type casting.
  • Declared functions as static (better scoping + performance).
  • Moved \is_callable($callback) === false as the execution costs less than previous in Router.php.
  • Changed ob_get_contents to ob_get_clean.
  • Added type hints to methods parameters/return type.
  • Moved request-types constants from abstract Route class to global Request-class and changed references.
  • Changed code to use new global request-type constants.
  • Optimized InputHandler class so it only parses inputs once when calling all-method.
  • Forced csrf-token post-value are now available for all Request::$requestTypePost request-methods.
  • Change variable name $values to $settings in Route::setSettings and related methods.
  • Updated link to demo-project in README.
  • Updated README.
  • Removed unused class references.
  • Removed escape from - in reg-ex as it's only required when next to character-class.
  • Removed legacy .yml configuration.
  • Removed .idea folder.
  • Other minor cleanup, bugfixes & optimisations.
  • Tests: Added unit-tests for default-namespace tests (rewrite + append cases).
  • Tests: Added more comprehensive php-unit tests for bootmanagers including findUrl.
  • Tests: Changed TestRouter so host-name is always set when using php-unit.
  • Tests: Added php-unit-test for input()->all() method.
  • Tests: Fixed issues with reg-ex and php-unit tests.
  • Tests: Added ClassLoader php-unit tests.
  • Tests: Added php-unit tests for enabled/disabled multi-routing.
  • Tests: Added file tests for InputHandler.
  • Tests: Added unit-tests for Request::getContentType parsing.
  • Tests: Added unit tests for file arrays.
  • Tests: Added unit-tests for Request::getIp.
  • Tests: Added unit-tests for group domain when using domain with no parameter.