You may know that a route's handler can return a variety of different data types. For example, to list only a few, we could return a
Response instance, or a
JsonResponse, or a simple string, or an array, or an Eloquent model, or an object with a
__toString() method, or an object that implements the
Responsable interface. Have you ever wondered how Laravel is allowing for this? Let's read the Laravel source code and figure out for ourselves!
Published on Sep 16th, 2019.