Download the PHP package fracture/routing without Composer

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

Fracture\Routing

Build Status Code Coverage Scrutinizer Packagist version

Introduction

This component is a simple routing library, that is made to be easily compatible with other libs. It does not include any functionality for dispatching. Instead it focuses on "packaging" the user's input in an abstracted representation of request.

Installation

You can add the library to your project using composer with following command:

It will also install fracture/http as a dependency.

Usage

The following code illustates the process of initializing the abstraction of an HTTP request and routing said request.

Definition of routes

The import() method of the router expects a list of defined routes. Each route is an array containing 'notation' element. It also can optionally have 'conditions' and 'defaults' fields.

When routers is attempting to match the URI to the list of defined routes, it iterates starting from top element and continues till either a match is found or the list has ended. Therefore to increase the priority of any of defined routes, you move it higher in the list.

Notation format

The notation is a human-readable format for defining the structure of URI, which you are attempting to match. It can contain 3 identifiable sets of parts, all of which can be seen in this example:

document[/view]/:name[.:extension]

These parts are:

Conditions

For each route it is possible to define custom conditions, that the tokens will be expected to match. By default every token is attempting to match an URI fragment, that does not contain /\.,;?. To change this behavior each route definition can optionally have a conditions element.

The conditions are set as array of key => value pairs, where keys correspond to names of tokens and values contain regular expression fragments. This is demonstrated in the following excerpt from route configuration array:

In this example you see a notation with three defined tokens, where :name token is optional. There also are two custom conditions defines, assigned to tokens :name and :iteration.

Defaults

When URI pattern has optional parts, you inevitably will have some requests where those parts were missing. In which case by default the Fracture\Request will return null, when trying to retrieve that parameter. But this behavior is not always the most useful.

If you want for optional URI part to have defined fallback values, which are used, when fragment was absent. That can be done by appending the definition of a route:

In the example above, if notation is matched, but the corresponding was not present in URI, the request abstraction will receive "unnamed" as value for 'name' parameter.

This feature can also be used to add "silent parameters" for a matched URI:

By having these "silent parameters", your code is not restricted to only using string-values that were found in URI.

Use of routed request

See documentation for fracture/http.

Various tips

Cleaner configuration

In a real-world project your application will almost always have more than couple routes. Which can result in extensive configuration, that would make the initialization phase of your project (like a bootstrap file) hard to read and filled with clutter.

To prevent that, you can segregate the configuration into a dedicated file.

This can also be combined with environment variables, for differentiating between development, staging and production environments.


All versions of routing with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
fracture/http Version >=0.3.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 fracture/routing contains the following files

Loading the files please wait ....