While working on a project with Laravel, I thought that “I wish all these routes were created automatically”. Then, I’ve started to research a package about that but I couldn’t find a package I want.
I’ve decided to make a simple package for that. I’ve made some research about how can I create a new Laravel package because I’d not created any package for Laravel before. I’ve been using Laravel about 5 years, but this would be my first package for Laravel.
With this package; you will be able to generate routes automatically and configure some options about the Package by using its config file. Now, you can check the example for the Package below.
Firstly, you must install the package via the Composer command:
composer require izniburak/laravel-auto-routes
After that, you should add a new route definition by using
auto method that will come from laravel-auto-routes package.
# in routes/web.php or routes/api.php Route::auto('/test', TestController::class);
Just route prefix and the Controller file are enough for definition. If you want to change some options like
name , you can use the third parameter of the
After that, you can add a new controller:
class TestController extends Controller
* URL will be converted to "/test/foo-bar"
public function fooBar(Request $request)
// your codes
* URL will be converted to "/test/bar-baz"
public function barBaz(Request $request)
// your codes
That’s all. All methods in your Controller will be generated to compatible endpoints automatically.
You can use parameters, HTTP methods, and more in your Controller. If you want to learn more details about the package, you can check the Github page:
Auto Route Generating Package for Laravel.
I hope this package would be useful to everyone and help them.
If you have any suggestions or ideas about the package, Please feel free to give them. I’d love to hear your feedback.