In this episode, we're setting up all the basics we need to get started with our Laravel app's like functionality.
First, we start with a fresh Laravel project and double-check that Redis is installed and accessible. You'll see a quick tour of how to check Redis on your machine (using redis-cli
), and also some alternatives for running Redis if you're using tools like Laravel Herd or db-engine. Once you've confirmed Redis is running, you'll update your Laravel environment configuration (in the .env
file) to make sure everything is connected—the right host, port, and client settings.
With Redis all set, the next chunk focuses on building the app scaffolding. We generate a Comment
model and a migration for a comments table. The table includes a body (text field) and a user association. After migrating, we set up a factory for generating fake comments and link them up to fake users (also generated). This gives us some dummy data to work with throughout the rest of the series.
Next, we wire up a basic route and a view where all the comments will show up. The comments are looped out in the view, just rendering their text for now, and we drop in a simple form (for liking, coming soon!).
Finally, because we haven't set up full authentication, we add a quick way to fake-sign-in a user, letting us test out liking as if we were logged in. We also show the current (fake) user's name at the top of the page.
By now, you should have a working page that shows fake comments and a signed-in user, all set up and ready for the next steps where we actually build the liking feature.