jmarcos16/mini-router 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jmarcos16/mini-router

最新稳定版本:v1.0.0

Composer 安装命令:

composer require jmarcos16/mini-router

包简介

Mini Router for PHP

README 文档

README

Mine router

This is a simple router for PHP. It is a project that allows you to create routes using the PHP Attributes, it also allows you to pass parameters and Class that will be executed when the route is called, we also use the PSR-4 standard to autoload and some Libraries to help in the development of the project, such as: PHP-DI and Symfony HttpFoundation.

Requirements

  • PHP 8.0 or higher
  • Composer

Installation

composer install jmarcos161/mine-router

Usage

In the public/index.php file, you must include the vendor/autoload.php file and the Router class, as shown below:

require __DIR__ . '/../../vendor/autoload.php';

use MiniRouter\Router;
use Symfony\Component\HttpFoundation\Request;
use Src\Controllers\YourController;

$routes = [
    YourController::class,
];

$router = new Router($routes);

$router->handle(Request::createFromGlobals());

In the YourController class, you must create a method with the #[Route] attribute, as shown below:

use MiniRouter\Attributes\Route;

class YourController
{
    #[Route('/index')]
    public function index()
    {
        return echo 'Hello World';
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-13