VOOZH about

URL: https://deepwiki.com/hypervel/dispatcher/1.1-package-structure-and-dependencies

⇱ Package Structure and Dependencies | hypervel/dispatcher | DeepWiki


Loading...
Menu

Package Structure and Dependencies

Purpose and Scope

This document details the structural organization and dependency requirements of the hypervel/dispatcher package as defined in its composer.json1-46 It covers the package metadata, runtime requirements, framework dependencies, autoloading configuration, and the integration mechanism through ConfigProvider. For information about how these components interact at runtime, see Architecture. For details on how the package integrates into a Hypervel application, see Integration Guide.


Package Metadata

The hypervel/dispatcher package is defined with the following core metadata:

PropertyValue
Namehypervel/dispatcher
DescriptionThe dispatcher package for Hypervel
LicenseMIT
Version Branch0.3-dev (dev-main)
Minimum Stabilitydev

Keywords: php, hyperf, dispatcher, middleware, swoole, hypervel

The package is authored by Albert Chen (albert@hypervel.org) and is part of the larger Hypervel components repository hosted at https://github.com/hypervel/components.

Sources: composer.json1-22 composer.json38-45


Runtime and Language Requirements

PHP Version Requirement

The package strictly requires PHP 8.2 or higher as specified in composer.json24 This requirement enables the use of modern PHP features including:

  • Readonly classes and properties
  • Disjunctive Normal Form (DNF) types
  • Constants in traits
  • Enhanced type system improvements

Diagram: PHP Runtime Stack

The Swoole extension is implied through the Hyperf framework dependencies, as Hyperf is built on Swoole's asynchronous server architecture.

Sources: composer.json24


Framework Dependencies

The package depends on three core Hyperf framework components, all at version constraint ~3.1.0:

Dependency Matrix

PackageVersionPurpose
hyperf/context~3.1.0Request-scoped context storage for coroutine environments
hyperf/dispatcher~3.1.0Base dispatcher interfaces and implementations
hyperf/pipeline~3.1.0Pipeline pattern implementation for sequential processing

Diagram: Framework Dependency Graph

Dependency Details

hyperf/context composer.json25

  • Provides coroutine-safe context storage mechanism
  • Used by HttpRequestHandler to store request-scoped middleware configuration
  • Enables data sharing across async call boundaries

hyperf/dispatcher composer.json26

  • Contains the base HttpRequestHandler class that is overridden by this package
  • Provides PSR-15 compliant dispatcher interfaces
  • Core dispatching infrastructure

hyperf/pipeline composer.json27

  • Base pipeline implementation that Hypervel\Dispatcher\Pipeline extends
  • Implements the pipeline pattern for sequential middleware processing
  • Provides through(), send(), and then() methods

Sources: composer.json23-28


Autoloading Configuration

The package uses PSR-4 autoloading to map the namespace Hypervel\Dispatcher\ to the src/ directory:


Diagram: PSR-4 Autoloading Structure

Autoload Configuration


This configuration ensures that any class under the Hypervel\Dispatcher namespace is automatically loaded from the corresponding file path under src/. For example:

Fully Qualified Class NameFile Path
Hypervel\Dispatcher\Pipelinesrc/Pipeline.php
Hypervel\Dispatcher\ConfigProvidersrc/ConfigProvider.php
Hypervel\Dispatcher\AdaptedRequestHandlersrc/AdaptedRequestHandler.php
Hypervel\Dispatcher\Psr15AdapterMiddlewaresrc/Psr15AdapterMiddleware.php
Hypervel\Dispatcher\ParsedMiddlewaresrc/ParsedMiddleware.php

Sources: composer.json29-33


Integration Mechanism

ConfigProvider Registration

The package integrates with the Hyperf framework through the ConfigProvider class, which is registered in the extra.hyperf section of composer.json:


When a Hyperf application is bootstrapped, it automatically discovers and invokes this ConfigProvider to retrieve package configuration.

Sources: composer.json34-40

ConfigProvider Implementation

The ConfigProvider class src/ConfigProvider.php9-23 implements a single __invoke() method that returns configuration arrays:


Diagram: ConfigProvider Integration Flow

Class Map Configuration

The ConfigProvider returns configuration that maps the Hyperf framework's HttpRequestHandler class to a custom implementation located in the class_map/ directory:


Key Configuration Elements:

Configuration PathValuePurpose
annotations.scan.class_mapArray mappingDefines class overrides
HttpRequestHandler::classKeyHyperf's default handler class
__DIR__ . '/../class_map/HttpRequestHandler.php'ValueCustom implementation file path

This mechanism allows the package to override the default Hyperf\Dispatcher\HttpRequestHandler with a custom implementation while maintaining compatibility with code that depends on the original class name.

Sources: src/ConfigProvider.php1-23


PSR Standards Compliance

While not explicitly declared in composer.json, the package implements and adheres to multiple PHP Standard Recommendations (PSRs):

Implemented Standards


Diagram: PSR Standards Implementation

StandardPurposeImplementation
PSR-4AutoloadingConfigured in composer.json autoload section
PSR-7HTTP MessagesUsed for ServerRequestInterface and ResponseInterface types
PSR-11ContainerUtilized through Hyperf's DI container for middleware resolution
PSR-15HTTP HandlersImplemented by HttpRequestHandler, AdaptedRequestHandler, and adapted by Psr15AdapterMiddleware

The PSR-15 compliance is critical as it allows the package to:

  • Implement standard RequestHandlerInterface for request handling
  • Support standard MiddlewareInterface implementations from third-party packages
  • Bridge between PSR-15 middleware and Hypervel's closure-based middleware system

Sources: composer.json29-33 (PSR-4), High-level system diagrams (PSR-7, PSR-11, PSR-15 compliance)


Directory Structure Summary

The complete package structure follows this organization:


Diagram: Package Directory Structure

Directory/FilePurpose
src/Contains PSR-4 autoloaded source files under Hypervel\Dispatcher namespace
class_map/Contains custom implementations that override Hyperf framework classes
composer.jsonDefines package metadata, dependencies, autoloading, and Hyperf integration

Sources: composer.json1-46 src/ConfigProvider.php17


Stability and Versioning

The package is currently in development stability with branch alias 0.3-dev for the dev-main branch:

ConfigurationValue
minimum-stabilitydev
branch-aliasdev-main: 0.3-dev

This indicates the package is under active development and has not reached a stable 1.0 release. The ~3.1.0 constraint on Hyperf dependencies targets the 3.1.x release series with compatibility for patches and minor updates within that series.

Sources: composer.json38-45