...

/

Controllers

Controllers

Refresher on the concept of controllers in Laravel.

Introduction

In the previous lesson, we could define our routes request handling logic as closures in the route files. In larger applications, the route file will become long and messy. We can move the handling logic to “controller” classes to make our application codes neater and easy to understand.

Controllers are helpful to group-related request handling logic into a single PHP class. For example, a UserController class might handle all requests to create, show and delete users’ records.

Basic controller

To create a controller class, we can use the make:controller artisan command. This command will place the controller class in the ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy