Search code examples
phpframeworkslaravellaravel-3

Admin Routes (Nested Controllers or Bundles)



I'm studying the Laravel 3, 1 week ago, but didn't understand everything about the routes.

My main question is: how to create administrative routes? In the video lessons from Jeffrey Way (Tuts Premium), I could understand two things about it:

Nested Controllers (/application/controllers/admin/user.php)
Bundles (/bundles/user.php) - He did not say much about it.

Anyway, I noticed 2 things (obvious):

On both sides, I can have a route / admin / whatever.

But what the correct way?

I'm really very confused.


Solution

  • Laravel bundles are for developing modular code that you can reuse from application to application in Laravel. The Bundle itself is very much the same as the 'application' directory you have as standard in a Laravel install, allowing you to create modular sub applications within your project. I highly recommend you avoid bundles for the moment entirely and focus on learning the core functionality of Laravel.

    For your needs, place your routes within your routes.php file within the application directory and nest them to your hearts content. This will serve your purposes fine. If you're not building/using bundles, you don't need to use bundle routes.

    When you're comfortable with Laravels routing and you've built one or two apps you may well have an idea for a bundle that will help you develop your apps faster in the future. This is the time to start learning about bundle routing as it's the only way to link your application logic with your bundle and provide it with a URL schema.

    Hope that helps.