Download the PHP package york8/router without Composer

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

PHP-Router

Latest Stable Version Total Downloads Latest Unstable Version License

一个简单的基于 PSR 7 的 PHP 路由器,良好的分层和扩展结构

Authors

Easy to install with composer

Usage

How to use:

1. 创建带默认路由失败处理器的路由器对象,
2. 构建路由规则,将规则与处理器关联起来

通过实现 MatcherInterface 接口来实现自己的规则匹配器, 然后实现 匹配器从而定制自己的规则, 也可以使用 $rule->addMatcher 方法来给默认的规则实现(Ruler)添加额外的匹配器, 最后使用 $router->addRuler 来添加规则。

已实现的匹配器可以在这里找到:

  • Host匹配器:用来匹配请求头 Host
  • Method匹配器:用来匹配请求方法
  • Path匹配器:路径匹配器,用来匹配请求路径

路径匹配器支持正则匹配,定义如下:

使用说明:

  1. 正则表达式必须使用圆括号括起来“(patther)”,括号内的内容可以为空,表示匹配任意字符
  2. 命名正则表达式,冒号开头,形如":name"开始的单词命名紧跟的正则表达式,路径匹配成功后, 命名正则匹配到的路径值将返回给属性结果,可以通过 attrs[name] 捕获
  3. 路径默认是前缀匹配的,可以在路径末尾添加 "$" 来变成全路径匹配,如 "/foo" 可以匹配 "/foo/bar",但 "/foo$" 则不能能匹配 "/foo/bar"

格式示例如下:

普通路径前缀匹配;

非命名的正则表达式,不捕获任何路径值;

使用命名的空正则表达式,将捕获到路径中的某一节并将其赋值给 "name" 属性,通过 attrs 返回;

使用命名的表达式,捕获匹配到的路径值并赋值给 "foo"、"bar" 和 "name" 属性,通过 attrs 返回。

3. 初始化请求和响应对象

使用实现了 PSR 7 规范的第三方库来初始化构建请求对象和响应对象,如:

4. 路由请求获取到对应的处理器

attrs 用来接收路由过程中捕获到的参数信息,如路径规则中定义的的参数,具体返回值由使用的路由规则和匹配器决定。

5. 使用处理器处理请求

An Example Route

License

This project is licensed under the MIT License.

License can be found here.


All versions of router with dependencies

PHP Build Version
Package Version
Requires php Version ~7.1
psr/http-message 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 york8/router contains the following files

Loading the files please wait ....