Download the PHP package softwarepunt/minirouter without Composer

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

MiniRouter

A fast and lightweight router for PHP, compatible with PSR-7:

Installation

Install the package using Composer:

This package is compatible with PHP 8.2+.

Usage

Registering routes

Initialize a new instance of MiniRouter and start registering routes:

Incoming requests (PSR-7)

You will need a PSR-7 implementation, such as guzzlehttp/psr7, to provide incoming request data. For example:

Dispatching requests

Once your routes are registered, pass your request object (any PSR-7 compatible RequestInterface) to the router:

This call will return a PSR-7 compatible ResponseInterface.

If a matching route is found, your target function will be executed and its response will be returned. It can return its own response object, or a string.

Accessing the request

When your target function is called, you can ask for an instance of RequestInterface to access the request directly:

The request object will be injected automatically. The name and order of the parameter doesn't matter.

Routes with variables

When you register your routes, you can also use one or more URL variables that can then be injected into your target function:

Variables are defined in the route by using the $ prefix. Their values are automatically extracted from the request URL, and injected into your target function as named parameters (strings).

Routing to (controller) classes

You can also register routes that will construct a class instance, and invoke a specific method. This can help you organize your code, and is more typical for a model-view-controller (MVC) architecture.

You can use the optional before method to perform pre-flight checks and run common code - for example, to handle authentication before allowing routing to proceed.

Simple redirects

You can also use the registerRedirect utility function to quickly register HTTP 301 or 302 redirects:

Examples

Complete index.php


All versions of minirouter with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
psr/http-message Version *
technically/callable-reflection Version ^0.4.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 softwarepunt/minirouter contains the following files

Loading the files please wait ....