While working with Laravel, you may encounter a scenario in which route files need to be separated.In this case you will need to make some changes in the project. This process can often become a chore, I have often faced this problem so I developed a package to help you automate this kind of chore.
Run the following command:
composer require soysaltan/larasplitter
Register the service provider in config/app.php
Soysaltan\LaraSplitter\Provider::class,
Publish config file.
php artisan vendor:publish --tag=larasplitter
You can change the settings of your app from config/larasplitter.php
file
php artisan spl:it
After this command, you will be asked two questions.
- Please enter a api file name (the filename will be saved with '.api' suffix): foo
- Please enter an endpoint name: foos
Finally, you will get a message like
- You can find your 'SplitApiFooServiceProvider' class at '/path/to/app/Providers'
- Your 'foo.api.php' file has located at '/path/to/routes'
You can hit the endpoint you have created : /api/foos
- Laravel 5.3+
- PHP 5.6.4+
Soysaltan\LaraSplitter\Provider registers the route file you want to separate under the app/Providers folder. This register dynamically does the following:
foreach (glob(base_path('app/Providers/SplitApi*')) as $file) {
$className = basename($file, '.php');
$this->app->register("\App\Providers\\$className");
}
Each separate route file is mapped to a provider and registered in the system in this way.
Please see Releases for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see LICENSE for more information.