In this episode, we dive into adding routing to our application. We start by discussing what routing is and why it's important, and then we make some quick changes in our bootstrap/app
just to get things working. But rather than leaving it messy, we move toward a more organized setup by creating a new RouteServiceProvider
.
We set up the RouteServiceProvider
and register it in our config, so all our routing logic stays nicely separated. Next up, instead of building a routing system from scratch (which would be a massive job), we pull in a popular package: league/route
. This package sits on top of fast-route
and gives us cool extras like controller registration and middleware support.
Once it’s installed with Composer, we add the router to our service container and configure it with the correct strategy, choosing the standard ApplicationStrategy
for this project. After the setup, we walk through how to register a basic route and make sure everything is wired together.
We hit a small configuration hiccup, fix it, and test things out—at the end, we're able to see our new route is being recognized, even though we aren’t returning a visible response just yet. In the next video, we’ll focus on actually responding to incoming requests using the router. Stay tuned!