Download the PHP package componenta/router-app without Composer

On this page you can find all versions of the php package componenta/router-app. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package router-app

Componenta Router App

Application integration for componenta/router. The package adds #[Route] discovery, connects route cache generation to application cache compilation, registers the route locator as a class-finder listener, and provides route handler resolution through HTTP interceptors.

Runtime code that only matches routes, generates URLs, or dispatches route handlers without HTTP interceptors should depend on componenta/router. componenta/router-app belongs in application assembly code: it connects the router with class discovery, application cache compilation, and the interceptor pipeline.

Dependencies

PHP:

Requirement Version
PHP ^8.4

Packages:

Package Purpose
componenta/app Application boot cycle and discovery notification.
componenta/app-http HTTP boot target that loads the application pipeline file.
componenta/router Route records, matching, URL generation, dispatch middleware, and route cache loading.
componenta/class-finder Class scanning and listener notification.
componenta/config Shared configuration object and router config keys.
componenta/di Factory and autowire registration through ConfigProvider.
componenta/http-responder Optional Responder for non-PSR-7 handler results.
componenta/interceptor HTTP interceptor pipeline for InterceptedRouteHandlerResolver.
componenta/middleware-factory Middleware resolver registration for route handlers.
componenta/path-resolver Resolving route file paths relative to the application root.
componenta/reflection Reading #[Route] metadata from classes and inherited declarations.
componenta/tokenizer Class information passed by the scanner.
componenta/var-export Exporting compiled route arrays into PHP cache files.
psr/container Retrieving dependencies from the container.
psr/http-message Response contracts used by route handlers.
psr/http-server-middleware Middleware contracts used by route dispatch.

Install:

Register this provider after the runtime router provider. The order matters because router-app replaces the RouteLocatorInterface factory with the integration factory:

Registered Services

Componenta\Http\Router\App\ConfigProvider adds:

Service or key Registration
RouteLocatorInterface router-app RouteLocatorFactory, which selects the development or production locator.
InterceptedRouteHandlerResolver Factory for HTTP-interceptor route handler resolution.
RouteCacheCompiler Autowired route cache compiler.
RouterListCommand Autowired Symfony Console command for listing registered routes.
AppConfigKey::BOOTLOADERS Adds RoutingBootloader for HTTP applications.
ClassFinderConfigKey::LISTENERS Adds AttributeRouteLocator so #[Route] attributes are collected during discovery.
CompileConfigKey::LISTENER_COMPILERS Adds RouteCacheCompiler to the class-finder listener compiler list.
MiddlewareConfigKey::RESOLVERS Adds InterceptedRouteHandlerResolver to the middleware resolver list.
ConsoleConfigKey::COMMANDS Adds router:list to the console command graph.
RouterConfigKey::ROUTES_FILE Sets the default route file to config/routes.php.

Route records, Router, Routes, MatchRouteMiddleware, DispatchRouteMiddleware, RouteHandlerResolver, CompilerInterface, MatcherInterface, and GeneratorInterface stay in componenta/router.

HTTP Pipeline

RoutingBootloader runs only for the HTTP application scope. During boot it adds routing middleware to the HTTP boot target with priority 50:

Applications that register this provider do not add these two middleware manually. Put middleware that must run before routing, such as error handling or body parsing, into config/pipeline.php with a higher priority, for example 100.

Route Discovery

AttributeRouteLocator implements RouteLocatorInterface, ClassListenerInterface, and FinalizableListenerInterface. In development mode, RouteLocatorFactory returns this locator.

Flow:

  1. RouteLocatorFactory reads ConfigKey::ROUTES_FILE, resolves it through PathResolverInterface, and creates a base RouteLocator.
  2. AttributeRouteLocator loads explicit routes from that route file.
  3. During scanning, class-finder passes discovered classes to AttributeRouteLocator::handle().
  4. The locator reads #[Route] metadata through Reflection::getDeepMetadata().
  5. After scanning, finalize() sorts discovered attributes by priority from highest to lowest and adds them as RouteRecord instances.

Example:

The attribute only describes the route. Middleware and handler execution are owned by componenta/router and componenta/middleware-factory.

methods accepts a string ('GET'), a |-separated string ('GET|POST'), or an array (['GET', 'POST']). When multiple attribute routes can match the same URI, the route with the higher priority is added first.

Route File

ConfigKey::ROUTES_FILE remains the route entry file even when attributes are enabled. This package sets its default value to config/routes.php. Use that file for manual routes, groups, and shared route setup, or override the config key when the application keeps routes somewhere else.

In development, attribute routes are added to routes from this file. In production, the application should read the compiled route cache.

Development And Production

router-app RouteLocatorFactory selects the locator by environment:

Condition Factory result
APP_ENV=production Base componenta/router RouteLocatorFactory. It reads cache when cache use is enabled and the cache file exists.
Any other environment AttributeRouteLocator, which loads the route file and appends discovered attribute routes.

The base RouteLocatorFactory uses cache only when ConfigKey::COMPILED_PIPELINE is enabled and the cache file exists.

Route Cache Compilation

RouteCacheCompiler is registered through CompileConfigKey::LISTENER_COMPILERS. It supports only AttributeRouteLocator.

compile():

Configuration example:

Console Commands

When componenta/app-console is installed, this package contributes router:list through Componenta\App\Console\ConfigKey::COMMANDS.

The command resolves RouteLocatorInterface from the container and lists method, path, route name, group, and handler. It uses the same locator as the running application, so development mode includes routes from config/routes.php and discovered #[Route] attributes, while production mode uses the production locator and route cache behavior.

HTTP Interceptors

InterceptedRouteHandlerResolver lives in componenta/router-app because it integrates routing with the application HTTP interceptor pipeline. The base componenta/router package dispatches handlers directly through RouteHandlerResolver and does not depend on componenta/interceptor.

The provider registers it in the componenta/middleware-factory resolver list by default:

InterceptedRouteHandlerResolverFactory reads:

Dependency Source
CallableExecutorInterface Container.
PipelineInterface Container. Registered by componenta/interceptor.
Responder Container, when registered.

If Responder is not registered, route handlers must return ResponseInterface, MiddlewareInterface, or RequestHandlerInterface; other values fail during dispatch.

The HTTP interceptor pipeline is created by componenta/interceptor. Its factory always adds ParameterResolvingInterceptor, then appends interceptor service ids from Componenta\Interceptor\ConfigKey::HTTP_INTERCEPTORS. A typical HTTP application adds AttributeInterceptor::class to that list so route handlers can use #[Intercept].

Package Boundaries

Use componenta/router for:

Use componenta/router-app for:


All versions of router-app with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
componenta/app Version ^1.0
componenta/app-console Version ^1.0
componenta/app-http Version ^1.0
componenta/class-finder Version ^1.0
componenta/config Version ^1.0
componenta/di Version ^1.0
componenta/http-responder Version ^1.0
componenta/interceptor Version ^1.0
componenta/middleware-factory Version ^1.0
componenta/path-resolver Version ^1.0
componenta/reflection Version ^1.0
componenta/router Version ^1.0
componenta/scope Version ^1.0
componenta/tokenizer Version ^1.0
componenta/var-export Version ^1.0
psr/container Version ^2.0
psr/http-message Version ^2.0
psr/http-server-middleware Version ^1.0
symfony/console Version ^7.4 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package componenta/router-app contains the following files

Loading the files please wait ...