Download the PHP package alexoliverwd/basic-router without Composer

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

PHPUnit

Basic Router

This application is a minimalistic yet powerful PHP class designed to handle routing in web applications. It's a dependency-free solution that offers a straightforward approach to mapping HTTP requests to specific PHP functions or methods.

Installation

Preferred installation is via Composer:

Basic Usage

When a request comes in to the application, the Router instance will examine the request method (GET, POST, PUT, DELETE) and the requested URL. If a matching route is found, the associated callback function will be executed.

In this example, if a GET request is made to the root URL (/), the function function () { echo 'get'; } will be called, and the string "get" will be output.

Registering an endpoint

The method registers a new route in the routing system.

Parameters

  1. Method: The HTTP method (e.g., GET, POST, PUT, DELETE).
  2. Route: The URL pattern for the route.
  3. Callback: The callable function or method to be executed when the route is matched.

Return Value:

Executing registered routes

The method is the core of the routing system. It's responsible for:

  1. Parsing the Request: Extracts the requested URL path and HTTP method from the server environment.
  2. Matching Routes: Compares the parsed request against registered routes to find a matching route.
  3. Executing Callback: If a match is found, the associated callback function is executed.
  4. Handling 404 Errors: If no match is found, the registered 404 error handler is invoked.

Unregistering an endpoint

This method unregisters a previously registered route from the routing system.

Parameters

  1. Method: The HTTP method (e.g., GET, POST, PUT, DELETE) in lowercase.
  2. Route: The URL pattern of the route to be unregistered.

Return Value:

Handling 404 errors

The method registers a callback function to be executed when a 404 Not Found error occurs. This allows you to customize the error handling behavior for your application.

Parameters

  1. Callback: A callable function or method that will be invoked when a 404 error is encountered. This callback can be used to generate custom error messages, redirect to a specific page, or perform other error handling actions.

All versions of basic-router with dependencies

PHP Build Version
Package Version
Requires php Version >=8.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 alexoliverwd/basic-router contains the following files

Collapse All

src

  router.php
.gitattributes
.gitignore
.lando.yml
LICENSE
README.md
composer.json
composer.lock
phpstan.neon
phpunit.xml