Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
/ larasplitter Public archive

Laravel Api Splitter - Make your endpoints manageable

Notifications You must be signed in to change notification settings

paramientos/larasplitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

Decompose your Laravel route files

Latest Stable Version Total Downloads Latest Unstable Version License

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.

Getting Started

1. Install

Run the following command:

composer require soysaltan/larasplitter

2. Register (for Laravel < 5.5)

Register the service provider in config/app.php

 Soysaltan\LaraSplitter\Provider::class,

3. Publish

Publish config file.

php artisan vendor:publish --tag=larasplitter

4. Configure

You can change the settings of your app from config/larasplitter.php file

Usage

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

Requirements

  • Laravel 5.3+
  • PHP 5.6.4+

How it works

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.

Changelog

Please see Releases for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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