Download the PHP package phel-lang/router without Composer

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

Phel router

A data driver router for Phel.

Installation

Route syntax

Routes are defined as vectors. The first element is the path of the route. This element is followed an optional map for route data and an optional vector of child routes. The paths of a route can have path parameters.

Examples

Simple route:

Two routes:

Routes with data:

Routes with path parameters:

Routes with path parameter validation:

Routes with catch all parameters:

Nested routes:

Same routes flattened:

Router

Given a vector of routes a router can be create. Phel router offers two option to create a router. The first is a dynamic router that is evaluated with every new request:

The second router is a compiled router. This router is evaluated during compile time (macro) and is therefore very fast. The drawback is that routes can not be created dynamically during the execution of a request.

Path based routing

To match a route given a path the phel\router/match-by-path function can be used. It takes a router and a path as arguments and returns a map or nil.

Name based routing

All routes that have :name route data can be matched by name using the phel\router/match-by-name function. It takes a router and the name of route and returns a map or nil.

Generate path

It is also possible to generate a path for a give route and it's path parameters. The function phel\router/generate takes a router, the name of the route and a map of router parameters. It returns either the generate path as string or throws an exception if the route can not be found ore path parameters are missing.

Handler

Each route can have a handler functions that can are execute when a route matches the current path. A handler function is a function that takes as argument as phel\http/request and returns a phel\http/response.

A handler can be placed either at the top level of the route data using the :handler keyword or under a specific method (:get, :head, :patch, :delete, :options, :post, :put or :trace). The top level handler is used if a request method based handler is not found.

To process a request the router must be wrapped in the phel\router/handler method. This method returns a function that accepts a phel\http/request and returns a phel\http/response.

Middleware

Each router can have multiple middleware functions. A middleware function is a function that takes a handler function and a phel\http/request and returns a phel\http/response.

A middleware can be placed either at the top level of the route data using the :middleware keyword or under a specific method (:get, :head, :patch, :delete, :options, :post, :put or :trace).


All versions of router with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
phel-lang/phel-lang Version >=0.17
gacela-project/gacela Version >=1.9
symfony/routing Version >=7.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 phel-lang/router contains the following files

Loading the files please wait ....