VOOZH about

URL: https://deepwiki.com/hypervel/router/6-reference

⇱ Reference | hypervel/router | DeepWiki


Loading...
Menu

Reference

This page provides an overview of the reference documentation for the hypervel/router package, including contracts, supporting classes, and exceptions. These components define the public API that applications interact with.

The reference documentation is organized into three sections:

Package Structure

The hypervel/router package provides the following reference components:

TypeComponentLocationPurpose
ContractUrlGeneratorsrc/Contracts/UrlGenerator.phpInterface for URL generation (25 methods)
ContractUrlRoutablesrc/Contracts/UrlRoutable.phpInterface for model binding (3 methods)
ClassRouteHandlersrc/RouteHandler.phpRoute callback encapsulation and introspection
ExceptionInvalidSignatureExceptionsrc/Exceptions/InvalidSignatureException.phpThrown when URL signature is invalid
ExceptionUrlRoutableNotFoundExceptionsrc/Exceptions/UrlRoutableNotFoundException.phpThrown when model binding fails
ExceptionBackedEnumCaseNotFoundExceptionsrc/Exceptions/BackedEnumCaseNotFoundException.phpThrown when enum case not found
ExceptionInvalidMiddlewareExclusionExceptionsrc/Exceptions/InvalidMiddlewareExclusionException.phpThrown for invalid middleware exclusions

Component Relationships

The following diagram shows how the reference components relate to the core routing system:


Sources: src/Contracts/UrlGenerator.php1-151 src/Contracts/UrlRoutable.php1-32 src/RouteHandler.php1-117

Contracts Overview

The package defines two contracts in the Hypervel\Router\Contracts namespace:

UrlGenerator Interface

The UrlGenerator interface defines 25 methods organized into functional groups:

Method GroupMethodsPurpose
Named Routesroute(), signedRoute(), temporarySignedRoute()Generate URLs for named routes
Path URLsto(), query(), secure()Generate URLs from paths
Asset URLsasset(), secureAsset(), assetFrom()Generate URLs for static assets
Request Infofull(), current(), previous(), previousPath()Access current/previous request URLs
Signature ValidationhasValidSignature(), hasValidRelativeSignature(), hasCorrectSignature(), signatureHasNotExpired()Validate signed URL security
ConfigurationforceScheme(), forceHttps(), useOrigin(), formatHostUsing(), formatPathUsing(), setSignedKey()Configure URL generation behavior
Utilitiesformat(), formatScheme(), isValidUrl()Helper methods for URL manipulation

Implemented by: Hypervel\Router\UrlGenerator class
Documented in: Contracts and Interfaces

Sources: src/Contracts/UrlGenerator.php14-151

UrlRoutable Interface

The UrlRoutable interface defines 3 methods for model binding:

MethodReturn TypePurpose
getRouteKey()mixedGet the model's route key value
getRouteKeyName()stringGet the route key column name
resolveRouteBinding($value)Model|nullResolve model from parameter value

Implemented by: Application models that need route binding
Used by: SubstituteBindings middleware
Documented in: Contracts and Interfaces

Sources: src/Contracts/UrlRoutable.php9-32

Supporting Classes

RouteHandler Class

The RouteHandler class extends Hyperf\HttpServer\Router\Handler to provide route callback introspection capabilities:


Used by: RouteCollector class for route registration
Documented in: RouteHandler and Supporting Classes

Sources: src/RouteHandler.php1-117

Exceptions

The package defines four exception classes in the Hypervel\Router\Exceptions namespace:

Exception ClassThrown ByWhen Thrown
InvalidSignatureExceptionValidateSignature middlewareURL signature validation fails
UrlRoutableNotFoundExceptionSubstituteBindings middlewareModel cannot be resolved from route parameter
BackedEnumCaseNotFoundExceptionSubstituteBindings middlewareEnum case not found for route parameter
InvalidMiddlewareExclusionExceptionMiddlewareExclusionManagerInvalid middleware exclusion configuration

Exception Hierarchy


Documented in: Exceptions

Sources: Based on package structure and middleware implementations

Contract Usage Examples

Implementing UrlRoutable

Models that need to be bound to route parameters should implement UrlRoutable:


Type-Hinting UrlGenerator

Controllers and services should type-hint the UrlGenerator interface:


Further Reading

For detailed documentation on implementing and using these contracts, see:

Sources: src/Contracts/UrlGenerator.php1-151 src/Contracts/UrlRoutable.php1-32 src/RouteHandler.php1-117