Download the PHP package strukt/router without Composer

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

Strukt Router

A typed HTTP router with parameter matching, a middleware pipeline, reflection resolved actions, and form validation — built on the strukt4 packages.

Routes are declared against patterns such as /user/{id:int}, matched by a compiled regex with typed parameter extraction, guarded by a middleware chain, and dispatched by reflecting the action callable to inject the request, the response, services, or a validated form.

Install

Documentation

The full guide lives in docs/:

Page Covers
Architecture Layers, the dispatch pipeline, matching, exception mapping.
Routing Verbs, patterns, typed parameters, groups, named routes.
Middleware The pipeline, global vs route, the built-in sess/auth/authz.
Authentication verify(), permissions(), log in / log out flow, 401/403.
Forms Rule table, custom rules, custom messages, the 422 payload.
Responses Action return values, redirects, downloads, error mapping.
Dependency injection Parameter resolution, bindings, middleware constructors.
HTTP layer Strukt\Http classes and the contracts they implement.
Global helpers router(), request(), response(), route(), matcher().
The route CLI Listing registered routes with strukt-routes.
Testing Dispatching routes in Pest and asserting statuses.
Troubleshooting The failure catalogue and debugging toolkit.
API reference Signatures for every public class and method.

Examples

Runnable scripts covering routing, parameters, groups, middleware, forms, authentication, responses, service injection, and the helper API live in examples/:

Routing

Use one verb method per route, or any() to accept every common method. get(), post(), put(), patch(), delete(), options(), and head() all share the same shape.

Groups

Wrap a callback with group() to share a path prefix.

Named routes

name() assigns a route name for reverse generation with path().

Route options — name(), middleware(), permissions(), requiresAuth(), form(), and defaults() — mutate the registered route fluently and can be stacked in any order.

Parameters

A pattern is slash separated segments. A segment may be literal, a plain placeholder, a typed placeholder, a wildcard, or an optional placeholder.

Pattern Matches Type
{name} any segment string
{id:int} digits int
{price:float} decimal float
{on:bool} true / false bool
{word:alpha} letters string
{key:alphanum} letters, digits, _, - string
{slug} slug words string
{on:date} YYYY-MM-DD string
{id:uuid} UUID string
{rest:*} remaining segments string

Matched values are cast, so {id:int} hands an int to the action. An unknown type and a missing required placeholder both throw. Reverse generation through uri() or Router::path() respects the same rules and route defaults.

Middleware

Global middleware runs before every route; route middleware runs after that. Definitions may be a registered name, a class, an object, or a callable.

Three names are registered out of the box:

Name Class Purpose
sess Middleware\Session Attach the session store to the request.
auth Middleware\Authentication Resolve and bind the current user.
authz Middleware\Authorization Enforce required permissions.

Middleware resolves through constructor injection: a middleware class declares the services it needs (SessionInterface, AuthInterface, a $verify or $permissions callable) and the router supplies them from the per-request service map.

Authentication and permissions

verify() and permissions() configure how users and grants are resolved. Routes opt in with requiresAuth() and permissions([...]).

A missing user on an authenticated route stops with a 401; a user without the required permission receives a 403.

Forms

Attach a Strukt\Form\Form class with form(). The router submits the request values and validates before the action runs; a failing validation answers with a 422 carrying the errors as JSON.

Responses

An action may return a string (body), an array (JSON), a ResponseInterface, or null. Use the response() helper for typed responses and redirects:

The kernel maps exceptions to HTTP errors: 404 for an unknown path, 405 with an Allow header for a bad method, 422 for failed form validation, and 401 or 403 for the auth gates.

Helpers

Helper Purpose
router() The shared Router instance.
request($input, $method, $uri, $headers) Build a Request.
response($code, $headers) A fluent response builder.
route($path, $method, $input) Dispatch and return the response.
matcher($patterns) A standalone UrlMatcher.
redirect($url, $status = 302) A redirect response.
download($path, $filename) A file download.

HTTP layer

The package ships its own Strukt\Http stack implementing the strukt4/contract interfaces: Request (with createFromGlobals()), Response, ResponseBuilder, Download, and UploadedFile. There is no dependency on a framework HTTP layer.

Session stores live under Strukt\Http\Session: Native persists values and flashes in $_SESSION, and Cache persists them through a strukt/cache driver — memcached, the filesystem, or memory — so several processes or servers can share a session. Bind either with $router->session():

Cache needs the optional strukt/cache package. See HTTP layer and installation.


All versions of router with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
strukt/base Version v1.1.0
strukt/commons Version v1.2.0
strukt/contract Version v1.2.0
strukt/form Version v1.0.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 strukt/router contains the following files

Loading the files please wait ...