Skip to content

Organize Laravel routes by modules with ease. laravel-route-moduler helps you keep your routes structured, scalable, and maintainable.

Notifications You must be signed in to change notification settings

vaened/laravel-route-moduler

Repository files navigation

Laravel Route Moduler

Build Status Software License

Separate laravel routes by modules and submodules

└── routes
    └── api
        └── clients.php
        └── payments.php
        └── store.php

Installation

Laravel Route Moduler requires PHP 8.2. To get the latest version, simply require the project using Composer:

composer require vaened/laravel-route-moduler

Now. Publish the configuration file.

php artisan vendor:publish --tag='laravel-route-moduler'

Usage

Once the library is installed, you can start organizing your routes within the /routes/modules folder, which is the default location. If you prefer a different location, you can update it in the route-modules.php configuration file.

├── routes
    └── modules

Multiple Modules

The route-modules.php configuration file returns an array for a single module setup. However, you can configure as many modules as you need by extending this array.

└── routes
    └── api
    └── web
    └── app

This structure helps to keep your application’s routes organized, making maintenance and scalability easier.

Configuration

You can customize the behavior of the laravel-route-moduler package through the route-modules.php configuration file. Below are the available options:

path: Specifies where the route configuration files for the module are located. You can set this to a directory or a single file.

Example:
	Load all routes in a directory: 'path' => 'routes/modules'
	Single route file: 'path' => 'routes/users.php'

prefix: Adds a prefix to the module path when the module is created, helping to make modules independent and supplement filename prefixes.

Example: 
	'prefix' => 'admin'

named: If true, the route file name will be used as a prefix for the routes defined in that file.

Example: 
	If the file is users.php, all routes will be prefixed with users.

middleware: Defines the default middleware applied to all routes registered by the module.

Example: 
	'middleware' => ['web', 'auth']

These settings allow you to tailor the package to your application’s specific routing needs.

License

This library is licensed under the MIT License. For more information, please see the license file.

About

Organize Laravel routes by modules with ease. laravel-route-moduler helps you keep your routes structured, scalable, and maintainable.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published