蓝藻细菌/laravel-sub-routes

一个分割路由文件的插件

2.1.0 2019-05-07 03:24 UTC

This package is auto-updated.

Last update: 2024-09-07 15:18:03 UTC


README

  1. 一个简单的按文件夹分割路由的工具
  2. 默认通过文件名设置前缀
  3. 可以设置中间件或不设置(需要在config文件夹下创建一个file.php文件)
  4. 仅适用于laravel
  5. 至少需要laravel 5.5或更高版本
  6. 项目在laravel 5.7上创建

入门指南

  1. 下载并自行require(git clone或直接下载)
git clone https://github.com/Cyanobacteria/laravel-sub-route.git
  1. 使用composer
 composer require cyanobacteria/laravel-sub-routes

先决条件

laravel和至少版本5.5

安装

  1. 完成入门指南并成功
  2. 在laravelProjectRoot/App/ServiceProviders/RouteServiceProvider.php中使用
//in RouteServiceProvider.php

 public function map()
    {
        $this->mapApiRoutes(); //<--laravel originSet

        $this->mapWebRoutes(); //<--laravel originSet


        // we will add 
        $subRoute=new LaravelSubRoutes(['configPath'=>'yourConfigFileName']);
        $subRoute->mapSubRoutes(['subRouteFolderName'=>'yourSubRouteFolderName']);
        
        /*
        projectRootPath/config/yourConfigFileName.php
        projectRootPath/routes/yourSubRouteFolderName/
        */
      
        // we will add
    }

  1. php artisan route:clear

许可

此项目使用MIT许可证授权 - 有关详细信息,请参阅LICENSE.md文件