Full Changelog Starting from Version 3.3.0 and Above
Name | Description |
---|---|
Version Code | 3.3.2 |
Version Name | Nobu |
Published | 2023-10-04 09:21:54 |
Updated | 2024-10-04 09:21:54 |
General Overview
Luminova 3.3.0 introduces major updates and performance improvements. Key features of this release include:
- HMVC Support: Build applications using the Hierarchical Model-View-Controller (HMVC) modular architecture.
- Network Testing: Test applications on various network-connected devices with the NovaKit PHP development server.
- Static Page Cache Versioning: Utilize the
app.version
environment variable to manage cache versions. Previous versions can be specified as an array inpage.cache.app.versions
environment variable for rendering cached content: (e.g,page.cache.app.versions = [1.0.0, 1.1.0]
). - New Utility Classes: Enhanced functionality with the introduction of classes for:
- Event Handling
- XHtml Document Building
- Input Field Building
- Process Execution
New Features
HTTP Server: Introduced a new module for creating a simple and flexible HTTP server. This module allows you to open a socket connections to listen for incoming requests, including support for
WebSocket
andSocket.IO
requests. It also has routing capability to route request and handle real-time communications effectively.Routing: Introduced support for a generic method
ANY
(orRouter::ANY_METHODS
), enabling routing for any HTTP method, including custom request methods. This enhancement improves performance by allowing a single index to handle all methods instead of creating separate indexes for each HTTP method (e.g.,GET|POST|PUT|DELETE|PATCH
, etc.). By usingANY
, the router efficiently manages routes, reducing overhead and improve request handling.Routing Segment Placeholders : Added support for placeholder patterns, in both CLI and HTTP routing, applicable to both Attribute and Router method based routing to simplify the segment capturing making it more accessible for beginners compared to traditional regex patterns.
Routing Prefix Attribute: Introduced support for the
Prefix
attribute, allowing you to define specific URI patterns or prefixes that a controller class is allowed to handle. This ensures that all routes within the controller are scoped under a common path, providing better organization and easier management of routes in larger applications. It is particularly useful for grouping related routes, such as versioned API endpoints or modular components of the application.HTTP Network Request Response: Enhanced support for the
Stringable
interface, allowing the request response body to be easily converted to a string format suitable for network transmission.HTTP File Upload Object: Introduced a new method
getContent
and the constructor property$contents
(type:string|null
). This enhancement enables the reception and upload of files directly from a string, even when thetemp_name
is unavailable or not required, providing greater flexibility in file handling.HTTP Method Override Support: Introduced
_OVERRIDE_REQUEST_METHOD_
to enable spoofing of HTTP request methods. Clients can now send aPOST
orGET
request with a hidden input or query parameter named_OVERRIDE_REQUEST_METHOD_
to specify an alternative HTTP method. If this parameter is present, the server's request method will be overridden with the provided value, allowing applications to simulate methods likePUT
orDELETE
in environments that only supportPOST
orGET
. This feature enhances testing capabilities and improves compatibility with various client scenarios.HMVC (Hierarchical Model-View-Controller): Luminova now supports HMVC for modular application development. This feature is disabled by default and can be enabled through the environment variable
feature.app.hmvc
.XHTML Document Builder: A new class,
Luminova\Builder\Xhtml
, has been added to facilitate programmatic HTML document generation.Form Input Builder: The
Luminova\Builder\Inputs
class helps in dynamically generating form elements and input fields in HTML.Event Handling: Introduces
Luminova\Utils\Event
, a class for managing event listeners and callbacks.HMVC Controller Module Definition: The new
setModule
method in the application class allows defining the module name for controllers, facilitating template discovery within modules.Global Helper
uppercase_words
: This utility converts the first letter of each word to uppercase. It also handles underscores (_
) and hyphens (-
), converting them to spaces before applying capitalization.Global Helper
array_merge_recursive_replace
: Merges multiple arrays recursively. When two arrays share the same key, values from the second array overwrite those from the first. Numeric keys are appended only if the value doesn't already exist in the array.Global Helper
array_merge_recursive_distinct
: Merges arrays recursively, but unlike traditional recursive merging, it replaces duplicate values rather than appending them. When two arrays contain the same key, the value in the second array replaces the one in the first array.Global Helper
array_extend_default
: Merges two arrays, treating the first array as the default configuration and the second as new or override values. If both arrays contain nested arrays, they are merged recursively, ensuring that default values are preserved and new values are added where applicable.
Optimizations & Updates
HTTP Request Class: Enhanced the HTTP request constructor to support the creation of custom HTTP request objects, including request methods, headers, body, and files. Improved the capturing of incoming requests for better performance, incorporating support for
Stringable
interface to convert the request body to a string.Improved
escape
Function: The globalescape
function has been enhanced to usehtmlspecialchars
for both HTML and attribute contexts, eliminating unnecessary initialize to the escaper class.Routes Attribute Compiler: This class has been optimized to efficiently handle controller classes with a defined
Prefix
attribute, ensuring that routes are properly scoped and organized. It also processes attributes more effectively, by storing cached attributes by prefix resulting in improved performance.NovaKit Command Enhancements: The
create:controller
command now supports the HMVC modular pattern. A new argument-module
has been introduced to specify the module name when generating controller classes.Sitemap Generator: Optimized sitemap generator to skips
404
error URLs. This version also introduces the followingpublic
properties:- $includeStaticHtml: (
bool
) When set to true, this property includes static.html
URLs in the sitemap. - $skipStaticHtml: (
array<string,string>
)This property allows the definition of specific URL patterns to exclude from static URL generation, providing more control over the sitemap content. - $changeFrequently: (
string|null
) This property allows you to define the frequency of URL changes, offering search engines valuable insights for indexing.
- $includeStaticHtml: (
Changes & Renaming
Directory Change:
/resources/views/
has been renamed to/resources/Views/
for consistency.Controller Namespace Changes:
App\Controllers\MyHttpAndApiControllers
should be moved toApp\Controllers\Http\MyHttpAndApiControllers
for organizing HTTP-related controllers inside/app/Controllers/Http/
.App\Controllers\MyCommandControllers
should now be placed inApp\Controllers\Cli\MyCommandControllers
, moving all CLI controllers to/app/Controllers/Cli/
.
To-Do List
For Luminova versions older than 3.3.0
, the below changes are required manually.
1. Sitemap Configuration:
In your Sitemap Configuration Class, add new properties $changeFrequently
, $includeStaticHtml
and $skipStaticHtml
if it doesn't already exist.
// /app/Config/Sitemap.php
<?php
namespace App\Config;
use \Luminova\Base\BaseConfig;
final class Sitemap extends BaseConfig
{
/**
* Indicates how frequently the page is likely to change in the sitemap.
*
* @var ?string $changeFrequently Set to one of the valid frequency values to indicate how often the page is likely to change, or `null` to disable.
*/
public ?string $changeFrequently = null;
/**
* Determines whether to include a static `.html` version of URLs in the sitemap XML.
*
* > **Note:** By default the start URL will not include the `.html` (e.g, `https://example.com/`).
*/
public bool $includeStaticHtml = true;
/**
* List of URL patterns to skip when generating static `.html` versions in the sitemap.
*
* @var array $skipStaticHtml An array of URL patterns to exclude from static `.html` generation.
*/
public array $skipStaticHtml = [
'*/docs/*/download'
];
// Other Properties
}
2. Update Controller Class Namespaces
To adhere to the new directory structure, you should create two new folders, Http
and Cli
, inside your Controllers
directory. Move all HTTP controllers to app/Controllers/Http/
, and all CLI command controllers to app/Controllers/Cli/
.
app/
/Modules/ (for HMVC Modules)
Controllers/ (Base Controllers)
Http/
Cli/
Foo/
Models/
Views/
Controllers/ (Foo Controllers)
Http/
Cli/
Controllers/ (for MVC Controllers)
Http/
Cli/
HTTP Controller Example:
// /app/Controllers/Http/HttpController.php
<?php
namespace App\Controllers\Http;
use Luminova\Base\BaseController;
class HttpController extends BaseController
{
//...
}
Command Controller Example:
// /app/Controllers/Cli/CommandController.php
<?php
namespace App\Controllers\Cli;
use Luminova\Base\BaseCommand;
class CommandController extends BaseCommand
{
//...
}