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

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

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

webservis/php-router

Composer 安装命令:

composer require webservis/php-router

包简介

Simple PHP Router Example

README 文档

README

This is a simple PHP router class that can be used to define routes for web applications.

Usage

  1. Installation

    First, you need to include the Route.php file in your project. You can do this by copying the content of the Route.php file into your project or by using Composer.

    composer require webservis/php-router
  2. Basic Usage

    <?php
    require_once 'vendor/autoload.php'; // Adjust this based on your project's structure
    
    use Webservis\Route;
    
    $router = new Route();
    
    $router->get('/', function () {
        echo "Hello, World!";
    });
    
    $router->get('/about', function () {
        echo "About Us Page";
    });
    
    $router->dispatch();
  3. Defining Routes

    $router->get('/products/:id', function ($id) {
        echo "Product ID: $id";
    })->name('product');
    
    $router->get('/categories/:slug', 'CategoryController@show')->name('category.show');
  4. URL Generation

    $productUrl = $router->url('product', ['id' => 123]);
    echo "Product URL: $productUrl";
  5. Subdomain Routing

    $router->subdomain('admin', function () {
        Route::get('/dashboard', 'AdminController@dashboard')->name('admin.dashboard');
    });
  6. Prefix Routing

    Route::prefix('/admin/auth')->group(function (){
        Route::get('/?', 'Auth@index')->name('auth');
        Route::get('/login', 'Auth@login')->name('auth/login');
        Route::get('/logout','Auth@logout')->name('auth/logout');
        //Route::get('/auth',function(){return 'This page is Authentification page';})->name('auth');
        Route::redirect('/auth/signin','/auth/login');
    });
  7. Read More

    For more details and advanced usage, please refer to the documentation in the docs directory.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2024-02-04