theanadimukt / routes-dir-iterator
Iterate nested directories for segregated routes
Fund package maintenance!
theanadimukt
Requires
- php: ^8.0
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.11.3
Requires (Dev)
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.2
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.1
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.29
This package is auto-updated.
Last update: 2024-04-09 08:30:20 UTC
README
This package contains a RoutesDirIterator
facade class that you can use to register segregate routes from nested directories at one place.
Installation
You can install the package via composer:
composer require theanadimukt/routes-dir-iterator
Usage
For example, routes for admin and guest has written in seperate files in nested directory structure for clean code.
routes
├── admin
│ ├── posts.php
│ ├── routes.php
│ └── settings
│ ├── permissions.php
│ └── roles.php
├── guest
│ └── routes.php
└── web.php
posts.php - Add relevent routes to file
use Illuminate\Support\Facades\Route; Route::get('/posts', function () { return view('admin.posts.index'); });
web.php - Use of package's RoutesDirIterator
facade class.
use TheAnadimukt\RoutesDirIterator\Facades\RoutesDirIterator; use Illuminate\Support\Facades\Route; Route::middleware('auth') ->prefix('admin') ->name('admin.') ->group(function () { RoutesDirIterator::read(__DIR__ . "/admin"); }); Route::middleware('guest') ->group(function () { RoutesDirIterator::read(__DIR__ . "/guest"); });
Under the hood package will do the necessary work to register all segreagated routed and make it publishable.
List all published routes in using command
php artisan route:list
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.