How dunneeee/dunnserver works
Main Components
• DunnServer Core: Represented by DunnServer.php and the base setup in src/Base (e.g., the Dunn class). This is the central hub where requests enter.
• HTTP Layer: Found under src/Http, these modules (Request, Response, HttpAction, FileUpload) handle request parsing, response formatting, and actions on HTTP data.
• Middleware: Located under src/Middlewares, this includes various filters (CorsFilter, DoFilter, Filter, etc.) and the FilterChain which intercepts and manages request/response processing.
• Routing: Contained in src/Router (Route, RouteStore, and Router), which determines which controller should process the request based on URL mapping.
• MVC Components: Under src/MVC, including Controller, ControllerAction, and View. These classes allow the separation of concerns by handling business logic and presentation.
• Utility Modules: In src/Utils with helper classes like DunnArray, DunnFile, and DunnMap that support reusable functions across the project.
Out Relationships and Interactions
• The HTTP Layer (Request and Response objects) encapsulates the request details.
• Next, the request flows through the Middleware chain (using FilterChain and its associated filters), ensuring cross-cutting concerns like CORS and file handling are applied.
• The request is then passed to the Router, which uses its RouteStore to match the URL against registered routes.
• Once a route is determined, the appropriate controller from the MVC layer (using Controller and ControllerAction) will be invoked. The controller ultimately uses a View to generate the response.
• Utility classes support operations in various components, providing common data structures or file operations.
Important Architectural Details and Patterns
• Emphasis on separation of concerns: HTTP handling, middleware processing, routing, and MVC segments are clearly distinguished.
• OOP principles: Inheritance and modular design are visible through well-organized namespaces (Base, Http, MVC, Middlewares, Router, Utils).
• Inspired by HttpServlet: The design follows a clear request lifecycle similar to Java’s servlet model with emphasis on filters (middlewares) and controllers.