kirschbaum-development/laravel-route-file-macro

Route macro that easily loads a route file without unnecessary method calls.
24,616 5
Install
composer require kirschbaum-development/laravel-route-file-macro
Latest Version:1.4
PHP:>=7.2.5
License:MIT
Last Updated:Mar 17, 2026
Links: GitHub  ·  Packagist
Maintainer: Kirschbaum

Laravel Route File Macro

Latest Version on Packagist Total Downloads

This package allows you to load a routes file directly from the Laravel Router.

Requirements

This package requires Laravel 5.7 or higher.

Due to Laravel 7's PHP version requirement, if you need support for PHP 7.1, please use version 0.2 of the package.

Installation

You can install this macro via composer:

composer require kirschbaum-development/laravel-route-file-macro

Usage

Single Item

Route::file accepts a single file path or SplFileInfo object and cannot be used with multiple paths or file objects.

Route::file(base_path('routes/admin/users.php'));

$files = File::files(__DIR__.'/routes');
Route::files($files[0]);

Multiple Items

Route::files accepts an array of file paths or an array of SplFileInfo objects and cannot be used with a single path or file object.

Route::files([
    base_path('routes/admin/posts.php'),
    base_path('routes/admin/users.php')
]);

$files = File::files(__DIR__.'/routes');
Route::files($files);

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email david@kirschbaumdevelopment.com or nathan@kirschbaumdevelopment.com instead of using the issue tracker.

Credits

Sponsorship

Development of this package is sponsored by Kirschbaum Development Group, a developer driven company focused on problem solving, team building, and community. Learn more about us or join us!

License

The MIT License (MIT). Please see License File for more information.

Related Packages

kirschbaum-development/laravel-queue-batch-retry

Package to retry failed jobs in batch using custom filters

359,907 51
kirschbaum-development/livewire-filters

Livewire Filters is a series of Livewire components that provide you with the to...

4,093 16
kirschbaum-development/filament-diffs

A Filament plugin that wraps @pierre/diffs to render beautiful file diffs and sy...

2,745 12
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

634,760,849 9,707