Download the PHP package njeaner/router without Composer

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

PHP Simple Fast Router

A simple PHP fast router

Installation

How to use it

Router and Routes Initialization

Initialization without ContainerInterface parameter

Initialization with ContainerInterface parameter

For complexe projects that need a container to resolve route callback, route middlewares or route policy arguments, you can initialize router passing an instance of \Psr\Container\ContainerInterface. by default, njeaner\router package recommand njeaner\container-di package that was used to process package tests; but you can use any other container package that implements \Psr\Container\ContainerInterface.

Register routes

any of these methods beyond return and instance of \Njeaner\Router\Routes\Route

Route name

Route name argument can be null or empty, then route can will be used as route name

Route path

Route path accept parameters that can be indicated using to format:

Route callback

Route callback accept several formats:

Route resolution

\Njeaner\Router\Router::resolve() function allow user to process some request object to retrieve matched route previously registered in \Njeaner\Router\Router instance. This method accept two arguments

Resolving and returning matched route allow user to decide the moment that he want to process route callback function.

Processing route callback function (run route callback)

\Njeaner\Router\Router::run() function allow user to process matched route callback function. This method accept one argument: an instance of \Psr\Http\Message\ServerRequestInterface, $request.

route callback can return any type of value (string, array, stringable object, psr7 response object), but returned value will be convert by \Njeaner\Router\Router::run() function to a \Psr\Http\Message\ResponseInterface instance

By default, Njeaner\Router\Routes\Route instance is able to resolve route path parameters, convert these parameters as route attributes, inject these attributes and request instance into route callback function if that is necessary.

For most complex route callback arguments resolution, the injection of a container instance to router instance is required.

Route middlewares

route middlewares are called and processed before processing route callback function. This allow user to perform some action when some route match current request path. Route middleware can be a callable function, an invokable class, an array containing middleware classname with it method name, or a name of \Psr\Http\Server\MiddlewareInterface class.

middleware is set to route using \Njeaner\Router\Router::middleware() function or \Njeaner\Router\Router::middlewares() to set several route middlewares. Middleware callable function accept to arguments:

NOTE: last middleware response is converted to \Psr\Http\Message\ResponseInterface.

Route policy

Route policy can be a boolean value, a callable classname, a callable function or an array containing Policy classname with it callable Method. Policy allow execution of \Njeaner\Router\Router::run() function only if it value or processed value is true.


All versions of router with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
psr/http-server-middleware Version ^1.0
psr/http-message Version ^2.0
psr/container Version ^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 njeaner/router contains the following files

Loading the files please wait ....