Download the PHP package amphp/http-server-router without Composer

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

http-server-router

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. This package provides a routing RequestHandler for amphp/http-server based on the request path and method using FastRoute.

Installation

This package can be installed as a Composer dependency. You should specify amphp/http-server as a separate dependency.

Usage

Router implements RequestHandler, which is used by an HttpServer to handle incoming requests. Incoming requests are routed by Router to other RequestHandlers based on the request path.

Routes can be defined using the addRoute($method, $uri, $requestHandler) method.

Matched route arguments are available in the request attributes under the Amp\Http\Server\Router key as an associative array. Please read the FastRoute documentation on how to define placeholders.

Middleware

You can stack all routes with a common set of middleware using addMiddleware($middleware). Each middleware is called in the order of the addMiddleware() calls. The router will not invoke any middleware for the fallback handler.

Note Per-route middleware can be added by using Amp\Http\Server\Middleware\stackMiddleware() before passing the RequestHandler to addRoute().

Fallback

If no routes match a request path, you can specify another instance of RequestHandler which will handle any unmatched routes. If no fallback handler is provided, a 404 response will be returned using the instance of ErrorHandler provided to the Router constructor.

Note Middleware defined by Router::addMiddleware() will not be invoked when a request is forwarded to fallback handler. Use Amp\Http\Server\Middleware\stackMiddleware() to wrap the fallback request handler with any middlewares needed first.

Example

A full example is found in examples/hello-world.php.

Limitations

The Router will decode the URI path before matching. This will also decode any forward slashes (/), which might result in unexpected matching for URIs with encoded slashes. FastRoute placeholders match path segments by default, which are separated by slashes. That means a route like /token/{token} won't match if the token contains an encoded slash. You can work around this limitation by using a custom regular expression for the placeholder like /token/{token:.+}.

Security

If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.

License

The MIT License (MIT). Please see LICENSE for more information.


All versions of http-server-router with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
amphp/amp Version ^3
amphp/cache Version ^2
amphp/http Version ^2
amphp/http-server Version ^3
amphp/socket Version ^2
nikic/fast-route Version ^1
psr/log Version ^1|^2|^3
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 amphp/http-server-router contains the following files

Loading the files please wait ....