Download the PHP package icanboogie/routing without Composer

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

Routing

Packagist Code Coverage Downloads

The icanboogie/routing package handles URL rewriting in native PHP. A Request is mapped to a Route, which in turn is mapped to a Responder. If the process is successful a response is returned. Events are emitted along the way to allow listeners to alter the request or the response, or recover from failure.

The following example is an overview of request processing. The routing components are part of the stack of responder providers.

Installation

A route

A route is represented with a Route instance. Two parameters are required to create an instance: pattern and action. pattern is the pattern to match or generate a URL. action is an identifier for an action, which can be used to match with a Responder.

The route pattern

A pattern is used to match a URL with a route. Placeholders may be used to match multiple URL to a single route and extract its parameters. Three types of placeholder are available:

Additionally, the joker character *—which can only be used at the end of a pattern—matches anything. e.g. /articles/123* matches /articles/123 and /articles/123456 as well.

Finally, constraints RegExp are extended with the following:

You can use them in any combination:

Route providers

Route providers are used to find the route that matches a predicate. Simple route providers are often decorated with more sophisticated ones that can improve performance.

Here is an overview of a route provider usage, details are available in the Route Providers documentation.

Responding to a request

A request can be dispatched to a matching Responder provided a route matches the request URI and method.

Controllers

Previous examples demonstrated how closures could be used to handle routes. Closures are perfectly fine when you start building your application, but as soon as it grows, you might want to use controller classes instead to better organize your application. You can map each route to its ActionTrait to group related HTTP request handling logic into a single controller.

Controller response

When invoked, the controller should return a result, or null if it can't handle the request. The result of the action() method is handled by the __invoke() method: if the result is a Response instance, it is returned as is; if the Response instance attached to the controller has been initialized (through the $this->response getter, for instance), the result is used as the body of the response; otherwise, the result is returned as is.

Before the action is executed

Controller\BeforeActionEvent is emitted before the action() method is invoked. Listeners may provide a response and thus cancel the action. Event hooks may also use this event to alter the controller before the action is executed.

After the action is executed

Controller\ActionEvent is emitted after the action() method was invoked. Listeners may alter the result of the method.

Basic controllers

Basic controllers extend from ControllerAbstract and must implement the action() method.

[!NOTE] The action() method is invoked from within the controller, by the __invoke() method, and is better defined as protected. The __invoke() method is final, thus can't be overridden.

Although any class implementing __invoke() is suitable as a controller, it is recommended to extend ControllerAbstract as it makes accessing your application features much easier. Also, you might benefit from prototype methods and event hooks attached to the ControllerAbstract class, such as the view property added by the icanboogie/view package.

The following properties are provided by the ControllerAbstract class:

Action controllers

Here is an example of an action controller, details are available in the Action controllers documentation.

Exceptions

The exceptions defined by the package implement the ICanBoogie\Routing\Exception interface, so that they're easy to recognize:

The following exceptions are defined:


Continuous Integration

The project is continuously tested by GitHub actions.

Tests Static Analysis Code Style

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you're expected to uphold this code.

Contributing

See CONTRIBUTING for details.


All versions of routing with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-json Version *
icanboogie/http Version ^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 icanboogie/routing contains the following files

Loading the files please wait ....