定制 shanta280/easy_php_router 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shanta280/easy_php_router

Composer 安装命令:

composer require shanta280/easy_php_router

包简介

Lightweight, Easy, Simple, Single Class, fast PHP Router (Routing System)

README 文档

README

Lightweight, Easy, simple, fast PHP Router (PHP Routing System) (Single Class)

Single Class Route Easy to use Routing system for PHP Easy to Integrate Easy to Implement Easy to get Started Easy to modify

How to install

    composer require shanta280/easy_php_router

Basic Example

<?php

require_once __DIR__.'/../vendor/autoload.php';
// or 
// require_once path_to_file/EasyRouter.php


$r = new Shantanu\EasyRouter();

$r->get("/", function() {
    echo "Home page";
});

$r->get("/about/{name}", function($name="") {
    echo "About {$name}";
});

// good this page will be shown 
// when url does not maych any thing
// good for showing 404
$r->get("/{any}", function($any='') {
    echo $any;
});

$r->get("/contact", function() {
    echo "Contact Page";
});

$r->get("/services", function() {
    echo "Services Page";
});

$r->any("/anymethod", function() {
    // we can call this route with any method
});

// to set custom 404 page
$r->set404(function() {
    die("Custom 404 page");
});

$r->run();// this line is important, it starts the routing process

Supported Methods

$r->get("path", "callback")
$r->post("path", "callback")
$r->put("path", "callback")
$r->delete("path", "callback")
// another special method
$r->route("method", "path", "callback")
$r->any("path", "callback")
$r->set404("callback")

Supported Callback methods

// Closure method
$r->get("/", function() {
    // do something here
});
 
// namespace method
// this will call the index function of MainController
$r->get("/", "\Namespace\Controller\MainController::index");

// class method
// this will call the about method of MyClass
$r->get("/about", ["MyClass", "about"]);

// we can also use someting like below
$r->route("GET", "/someting", ["\Namespace\Controller\SomeController", "some_method"]);

More Info

in callback we can pass namespace\class, Just Class, Closure, more if you extend it.

统计信息

  • 总下载量: 27
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固