Download the PHP package bayfrontmedia/route-it without Composer

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

Route It

A fast, flexible router which can be used to quickly build RESTful web apps.

License

This project is open source and available under the MIT License.

Author

Bayfront Media

Requirements

Installation

Usage

Start using Route It

Default options:

Force lowercase

When force_lowercase_url is enabled in the $options array, all incoming requests which contain uppercase characters will be redirected via a 301 redirect to their lowercase counterpart. Query parameters will not be affected.

Automapping

When automapping is enabled, Route It will automatically attempt to dispatch the incoming request in the form of class/method/optional-parameter without having to define each individual route.

The incoming request must match the automapping route prefix, and classes must exist in the automapping namespace as defined in the $options array.

For example:

Using the above example, incoming requests would be automapped like so:

Endpoint Class Method Parameter
/app App\Pages\Home index
/app/customers App\Pages\Customers index
/app/customers/edit App\Pages\Customers edit
/app/customers/edit/5 App\Pages\Customers edit ['id' => 5]

Understandably, automapping does not provide a solution for every scenario, in which case, routes can be added.

Named routes

Named routes are helpful when using hyperlinks in controllers, views or templates. By referencing a named route instead of a specific URL, the hyperlink will stay up-to-date with your defined routes.

When dispatching a request using the dispatchToFallback methods, Route It will automatically insert an array of all named routes to the destination as a parameter with the key of routes, unless otherwise specified.

See documentation for these methods for more information.

Wildcards

Wildcards can be used when defining a route in order to dynamically define a path, and send its value to the destination as a parameter. The syntax is {type:name}, where type is the wildcard type, and name is the name of the parameter which is to be passed to the destination.

Wildcards include:

For examples, see addRoute.

Public methods


setHost

Description:

Sets the hostname for defined routes.

Parameters:

Returns:

Example:


getHost

Description:

Retrieves the hostname for defined routes.

Parameters:

Returns:


setRoutePrefix

Description:

Sets the route prefix for defined routes.

Parameters:

Returns:

Example:


getRoutePrefix

Description:

Retrieves the route prefix for defined routes.

Parameters:

Returns:


addFallback

Description:

Adds a fallback destination for given request method(s) when no route can be found. The response will be sent with a 404 HTTP status code.

Parameters:

Returns:

Example:

For more destination examples, see addRoute.


getFallbacks

Description:

Returns array of defined fallbacks.

Parameters:

Returns:


addRedirect

Description:

Adds a redirect. Wildcards can be used in the path.

Parameters:

Returns:

Example:

For more path definition examples, see addRoute.


getRedirects

Description:

Returns array of defined redirects.

Parameters:

Returns:


addRoute

Description:

Adds a defined route. Wildcards can be used in the path.

Destinations can be a callable function, a named route, a file, or a $class->method(). Each route can have its own predefined parameter(s), and parameters can also be defined dynamically by a "wildcard".

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's. Named route names must be unique, as names which already exist are overwritten.

Returns:

Example:


any

Description:

Adds route for ANY request method.

Equivalent of calling addRoute('ANY'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


connect

Description:

Adds route for CONNECT request method.

Equivalent of calling addRoute('CONNECT'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


delete

Description:

Adds route for DELETE request method.

Equivalent of calling addRoute('DELETE'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


get

Description:

Adds route for GET request method.

Equivalent of calling addRoute('GET'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


head

Description:

Adds route for HEAD request method.

Equivalent of calling addRoute('HEAD'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


options

Description:

Adds route for OPTIONS request method.

Equivalent of calling addRoute('OPTIONS'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


patch

Description:

Adds route for PATCH request method.

Equivalent of calling addRoute('PATCH'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


post

Description:

Adds route for POST request method.

Equivalent of calling addRoute('POST'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


put

Description:

Adds route for PUT request method.

Equivalent of calling addRoute('PUT'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


trace

Description:

Adds route for TRACE request method.

Equivalent of calling addRoute('TRACE'...)

Parameters:

NOTE: Names should not be assigned to routes which include wildcards in the path. Named routes are only intended to define specific URL's.

Returns:

Example:


getRoutes

Description:

Returns array of defined routes.

Parameters:

Returns:


addNamedRoute

Description:

Adds a specific path as a named route.

This is helpful when wanting to reference a URL that is not defined as a route.

Parameters:

Returns:

Example:


getNamedRoutes

Description:

Returns array of named routes.

Automatically replaces wildcards with resolved parameters.

Parameters:

Returns:


getNamedRoute

Description:

Returns URL of a named route.

Automatically replaces wildcards with resolved parameters.

Parameters:

Returns:


resolve

Description:

Resolves the incoming HTTP request by searching for a matching redirect, route, automapped location, or fallback. Destination-specific parameters will overwrite global parameters of the same key.

The returned array consists of the following keys:

The destination will vary based on the type:

type destination
redirect URL
route Defined route
automap Class:method
fallback Defined callback

A DispatchException will be thrown if the request is unable to be resolved.

Parameters:

Returns:


dispatch

Description:

Resolves and dispatches the incoming HTTP request.

Destination-specific parameters will overwrite global parameters of the same key.

Parameters:

Returns:

Throws:

Example:

dispatchTo

Description:

Dispatches to a specific destination.

Destinations can be a callable function, a named route, a file, or a $class->method().

Parameters:

Returns:

Throws:

Example:

dispatchToFallback

Description:

Dispatches to fallback for current request method, or throws exception.

Fallback-specific parameters defined using the addFallback method will overwrite these parameters of the same key.

Parameters:

Returns:

Throws:

Example:

redirect

Description:

Redirects to a given URL using a given status code.

Parameters:

Returns:

Throws:

Example:


getResolvedParameters

Description:

Get array of all parameters present for the current route once resolved/dispatched.

Parameters:

Returns:


All versions of route-it with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-ctype Version *
bayfrontmedia/php-array-helpers Version ^2.0
bayfrontmedia/php-http-request Version ^3.1
bayfrontmedia/php-http-response Version ^2.0
bayfrontmedia/php-string-helpers Version ^2.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 bayfrontmedia/route-it contains the following files

Loading the files please wait ....