Pregunta


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.

¿Fue útil?

Solución

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.

Otros consejos

Neither way is really right or wrong, the beauty of Laravel is that there are so many ways to achieve the same thing so it's up to the developer to choose what works for them.

Personally I started by using nested controllers as they're much easier to get up and running. I would however recommend making the move to bundles. If you plan on sticking with Laravel (and you should) then it would make sense to build a bundle that includes the auth and components you use in each project already setup. That way you just need install the bundle and you're good to go.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top