- Add comprehensive error handling system with custom error pages - Implement professional enterprise-style design with Tailwind CSS - Create modular HMVC architecture with clean separation of concerns - Add security features: CSRF protection, XSS filtering, Argon2ID hashing - Include CLI tools for development workflow - Add error reporting dashboard with system monitoring - Implement responsive design with consistent slate color scheme - Replace all emoji icons with professional SVG icons - Add comprehensive test suite with PHPUnit - Include database migrations and seeders - Add proper exception handling with fallback pages - Implement template engine with custom syntax support - Add helper functions and facades for clean code - Include proper logging and debugging capabilities
63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Core;
|
|
|
|
/**
|
|
* NovaCore Middleware Pipeline
|
|
* Stackable middleware system
|
|
*/
|
|
class Middleware
|
|
{
|
|
private array $middlewares = [];
|
|
|
|
/**
|
|
* Add middleware to stack
|
|
*/
|
|
public function add($middleware): void
|
|
{
|
|
$this->middlewares[] = $middleware;
|
|
}
|
|
|
|
/**
|
|
* Run middleware pipeline
|
|
*/
|
|
public function run(string $method, string $uri): void
|
|
{
|
|
$index = 0;
|
|
$this->executeMiddleware($index, $method, $uri);
|
|
}
|
|
|
|
/**
|
|
* Execute middleware recursively
|
|
*/
|
|
private function executeMiddleware(int &$index, string $method, string $uri): void
|
|
{
|
|
if ($index >= count($this->middlewares)) {
|
|
return;
|
|
}
|
|
|
|
$middleware = $this->middlewares[$index++];
|
|
|
|
if (is_string($middleware)) {
|
|
$middleware = new $middleware();
|
|
}
|
|
|
|
if (is_object($middleware) && method_exists($middleware, 'handle')) {
|
|
$middleware->handle($method, $uri, function () use (&$index, $method, $uri) {
|
|
$this->executeMiddleware($index, $method, $uri);
|
|
});
|
|
} else {
|
|
// Continue to next middleware
|
|
$this->executeMiddleware($index, $method, $uri);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get all registered middlewares
|
|
*/
|
|
public function getMiddlewares(): array
|
|
{
|
|
return $this->middlewares;
|
|
}
|
|
}
|