Download the PHP package kissous/attribute-router without Composer

On this page you can find all versions of the php package kissous/attribute-router. 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 attribute-router

attribute-router

The compiled PHP 8 attribute router.

Declare routes with #[Route] attributes on controller methods. They are scanned once and compiled into a static PHP dispatch table — zero runtime reflection, zero external dependencies, PSR-7 compatible.

A lightweight option for small projects that want attribute routing without pulling in a framework or a larger routing component.

Requirements

Install

Quick start

1. Declare routes

A parameter {id} matches a single path segment ([^/]+) and is passed to the method by name.

2. Compile once (build step)

Pass --scan more than once to scan several directories. Run this in your build / deploy pipeline (and locally after changing routes); the generated file is a plain return [...] array that the dispatcher loads with require.

3. Dispatch at runtime

$result->parameters is keyed by parameter name, so spreading it (...) passes them as named arguments — order-independent and matching the method signature. Swap the new (...) line for your DI container when you have one.

The DispatchResult

Dispatcher::dispatch() returns an immutable DispatchResult:

Property Type Meaning
status DispatchStatus Found / NotFound / MethodNotAllowed
controller ?string matched controller FQCN (match only)
action ?string matched method name (match only)
parameters array<string,string> captured route parameters (match only)
name ?string route name, if declared (match only)
allowedMethods list<string> allowed methods (method-not-allowed only)

Helpers: isFound(), isNotFound(), isMethodNotAllowed().

How it works

ClassScanner reads #[Route] attributes via reflection and emits ScannedRoute DTOs. Compiler turns them into a readable, closure-free PHP file (static paths in a direct-lookup map, dynamic paths as anchored regexes). Dispatcher loads that file and resolves a request with array lookups and preg_match only. All reflection is confined to the scanner and runs at build time. See docs/architecture.md.

FAQ

Does it use reflection at runtime? No. Reflection is confined to the scanner and runs only when you compile.

What dependencies does it pull in? Only the PSR HTTP message interfaces.

Do I have to recompile after changing routes? Yes — re-run the compile command. Wire it into your build step; in development, run it whenever routes change.

Can I commit the compiled file? You can, but it is typically a build artifact written to var/ and gitignored.

Is it a full framework / does it call my controller? No. It resolves a request to a controller, action and parameters; you instantiate and invoke (directly or through your container), keeping it framework-agnostic.

What about route constraints, #[Get] aliases, URL generation, middleware? Planned for later minor versions — see the roadmap in docs/roadmap/.

Lightweight by design

The design trades a build step for a cheap runtime: no reflection, no attribute parsing, no object graph — just a map lookup and, for dynamic routes, a single preg_match. The aim is a small, dependency-free router that is easy to drop into a small project, not a replacement for full-featured routers.

Development

License

MIT — see LICENSE.


All versions of attribute-router with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
psr/http-message Version ^1.1 || ^2.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 kissous/attribute-router contains the following files

Loading the files please wait ...