Skip to content

Refactor RouteDispatcher and MiddlewareManager to rely on PSR-4 autoloading #336

@armanist

Description

@armanist

Currently, RouteDispatcher and MiddlewareManager use require_once to load classes dynamically.

This approach:

  • Breaks PSR-4 autoloading.
  • Prevents proper use of subfolders for controllers and middlewares.
  • Can lead to brittle code and maintenance issues.

Proposed changes:

  • Remove require_once from both classes.
  • Construct class FQCNs dynamically using the module namespace and class name.
  • Add class_exists() checks to provide clear error messages if a class is missing.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions