Download the PHP package phower/router without Composer

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

Phower Router

PHP routing package compliant with PSR-7.

Requirements

Phower Router requires:

Instalation

Add Phower Router to any PHP project using Composer:

Usage

Routing is the process to match and drive an HTTP request to a previously given route. This process requires a Router instance with one or more Routes to evaluate against the request.

Routes

Each Route must have a name and a definition. Optionally it may also have constraints, default values for optional segments and allowed methods.

A simple Route example to match requests to the root path ():

Another example for a Route matching requests to path, with a required argument and an optional argument:

Note that arguments are preceeded with a colon () and to make them optional we must use squared brackets.

To force an argument to some pattern we can specify a third argument in form of an associative array containing a regular expression for each constraint.

In previous example we may wish to constrain argument to only accept digits:

We can also provide default values for optional arguments. In case they are not specified in the the original request then the default value will take their place. It is also possible to attach other values to a Route using the defaults array:

Some routes are also expected to match against a request with a specific method. For example to just match requests we can tell that using a fifth argument in the Route signature

A static factory method is available to create routes from a configuration array:

Assembling a Route instance means to build its URL from the required arguments:

Router

Router is a stack of routes with methods to match a given HTTP request and to assemble URLs for a named route.

Creating a Router instance just requires an array containing weither Route instances or configuration arrays to instantiate routes:

Matching an HTTP request requires an instance of RequestInterface as argument:

We can also assemble a route by name from a Router instance containing that named route:

Running Tests

Tests are available in a separated namespace and can run with PHPUnit in the command line:

Coding Standards

Phower code is written under PSR-2 coding style standard. To enforce that CodeSniffer tools are also provided and can run as:

Reporting Issues

In case you find issues with this code please open a ticket in Github Issues at https://github.com/phower/router/issues.

Contributors

Open Source is made of contribuition. If you want to contribute to Phower please follow these steps:

  1. Fork latest version into your own repository.
  2. Write your changes or additions and commit them.
  3. Follow PSR-2 coding style standard.
  4. Make sure you have unit tests with full coverage to your changes.
  5. Go to Github Pull Requests at https://github.com/phower/router/pulls and create a new request.

Thank you!

Changes and Versioning

All relevant changes on this code are logged in a separated log file.

Version numbers follow recommendations from Semantic Versioning.

License

Phower code is maintained under The MIT License.


All versions of router with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.0
psr/http-message Version ^1.0
phower/arrays Version ^1.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 phower/router contains the following files

Loading the files please wait ....