Download the PHP package buffalokiwi/telephonist without Composer
On this page you can find all versions of the php package buffalokiwi/telephonist. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download buffalokiwi/telephonist
More information about buffalokiwi/telephonist
Files in buffalokiwi/telephonist
Package telephonist
Short Description Routes requests to somewhere for things
License MIT
Informations about the package telephonist
BuffaloKiwi Telephonist
Telephonist is a simple PHP router library, which is a program for mapping http requests to handlers based on various matching criteria.
Table of Contents
- [What's in the box?](#interfaces-and-implementations]
- Basic Routing
Interfaces and Implementations
Interfaces
- Handlers
- IArgumentResolver - Using the PHP Reflection API, determine the type, number and values of arguments used when invoking some method
- IRouteHandler - Route handlers are responsible for locating some endpoint and returning the content. This can be anything, a file, class, some global function, an RPC, etc.
- Route Objects
- IHTTPRoute - An object representing a potential destination and the requirements for connection.
- IHTTPRouteFactory - A factory optionally used to supply instances of IHTTPRoute to implementations of IHTTPRouter
- Route Options
- IHTTPRouteOption - Used to extend the conditions required for route matching. This can be anything, such as the HTTP Method, accept headers, authentication tokens, etc.
- IHTTPRouteOptions - A collection of IHTTPRouteOption
- Request for Routing
- IHTTPRouteRequest - Represents a HTTP Request message and exposes the relevant parts to the router
- Router
- IHTTPRouter - The program responsible for determining which route to invoke based on some client request
Implementations
-
Handlers ArgumentResolver ClassRouteHandler FunctionRouteHandler
-
Route Objects ArrayRouteFactory HTTPRoute ClassHTTPRoute DefaultHTTPRoute DefaultHTTPRouteFactory NestedArrayRouteFactory HTTPRouteFactoryGroup
-
Route Options DefaultHTTPRouteOptions HTTPRouteOption MethodRouteOption XMLHTTPRequestRouteOption
-
Request for Routing DefaultHTTPRouteRequest
- Router BasicRouter DefaultHTTPRouter
The most basic router possible
http://localhost displays: "This is the home page"
Adding arguments
Arguments can be added by using standard capture groups
http://localhost/1 displays: "Found digit 1"
We can used named arguments by using named capture groups like this
If named arguments are used, then ALL arguments must be named. Mixing of positional arguments with named arguments is not allowed.
In the following example, naming $id anything other than $id will throw an exception.