承接 chahal26/php-simple-router 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

chahal26/php-simple-router

最新稳定版本:2.0

Composer 安装命令:

composer require chahal26/php-simple-router

包简介

Simple Routing made with OOPS in PHP

README 文档

README

A simple & lightweight PHP Router made with Object Oriented PHP. Built with ❤️ by Sahil Chahal

It currently supports static routes only.

Prerequisites/Requirements

Installation

chahal26/php-simple-router can be easily installed using

    composer require chahal26/php-simple-router

Usage

Create an instance of \Chahal26\PhpSimpleRouter\Router, define some routes, and run it.

    require_once 'vendor/autoload.php';

    use Chahal26\PhpSimpleRouter\Router;

    /* Creating Route Instance */
    $router = new Router();

    /* Defining Routes */


    /* Execute Routes */
    $router->run();

Available Routing Methods

  • GET
  • POST

Defining Routes

Static Routes

$router->get('route', function() { /* ... */ });
$router->post('route', function() { /* ... */ });

With Controller

    $router->get('/about', '\App\Controllers\PagesController@about');

Or a namespace can also be defined

    $router->setNamespace('\App\Controllers');
    $router->get('/about', 'PagesController@about');

Example

    $router->get('/', function(){
        echo "<h1>Welcome To Home Page</h1>";
    });

    $router->get('/contact', function(){
        echo "<h1>Welcome To Contact Page</h1>";
    });

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-12