Releases: oladesoftware/httpcrafter
RouterFacade
What's new
RouterFacadeclass
Introduced a new
RouterFacadeclass to provide a simplified interface for route registration, pattern mapping and route path generation.
Bug fixes
- Pattern mapping fix
Full Changelog: v0.3.0...v0.4.0
[Router:generatePath] Generate path with dynamic value
Update existing generatePath() method in the Router class to generate paths with dynamic values. This should allow developers to create URLs with parameters or dynamic segments without manually concatenating strings.
Example:
Assuming dynamic segment userID
$router->generatePath('profile', [ 'userID' => 123 ]);
Output: '/account/profile/123'
set '?' to allow nullable for name parameter for Router addRoute function
- Set ? to allow nullable for name parameter for Router->addRoute()
Set PHP minimum requirement
Require PHP 8.2 and greater
Add redirection method to Response class
What's new?
- Add redirection method to Response class
Usage:
// Redirect to the specified URL with a 301 Moved Permanently status code
$response->redirect('https://www.example.com', 301);
// Redirect to the specified URL with a 302 Moved Temporary status code
$response->redirect('/new-page', 302);[release v0.1.3] Refactor Response and add interfaces for Authenticator and Authorization
Refactor Response Content-Length handling and add interfaces for Authenticator and Authorization
- Moved Content-Length calculation logic to a private
updateContentLength()method to improve encapsulation and reusability. - Updated
send()method to call theupdateContentLength()method before sending the headers. - Introduced interfaces for
AuthenticatorandAuthorizationto standardize authentication and authorization mechanisms.
**Hotfix:** Fixed the calculation of the Content-Length header in the Response class
Release Notes for v0.1.2
- Hotfix: Fixed the calculation of the Content-Length header in the Response class to ensure accurate length is set based on the body content.
- Issue Addressed: Previous implementation incorrectly calculated the Content-Length using strlen() on the length itself instead of the actual content length.
release v0.1.1
hotfixes: Content-Length calculation based on type
release v0.1.0
Enhancements to Httpcrafter
This release brings a significant restructuring of core components within the HTTP toolbox, along with the addition of a flexible routing solution. These updates enhance modularity and ease of use for developers looking to integrate individual tools.
Key Changes:
-
Refactor of Request and Response Classes
- The
Request.phpandResponse.phpfiles have been reorganized into thesrc/Http/directory, improving file structure and accessibility. - New interfaces—
RequestInterface.phpandResponseInterface.php—have been introduced, providing more flexibility for developers to implement custom request and response handling.
- The
-
Introduction of Router Class
- We've added the
Routerclass from the archived oladesoftware/router repository, which now serves as a foundational routing component within the HTTP toolbox. - The new
Routerclass is available atsrc/Router/Router.php, with corresponding tests intests/Router/RouterTest.php.
- We've added the
-
Updated Test Suite
- The directory structure for test files has been updated to align with the new organization:
tests/RequestTest.php→tests/Http/RequestTest.phptests/ResponseTest.php→tests/Http/ResponseTest.php
- The directory structure for test files has been updated to align with the new organization:
These updates further strengthen the modularity of the Httpcrafter, ensuring that each class can be used independently for a variety of use cases, while maintaining a clean and organized architecture.