Controllers move route handlers into classes that can be generated, injected and tested. This section builds the bookshop's controllers on Laravel 13.33 2,157 , with the products of Route Model Binding plus reviews and two users in SQLite 4,756 , and shows every kind of input and response. $B in the listings is http://127.0.0.1:8305, served by php artisan serve --port=8305. The figure shows the order of events: middleware runs before the controller is even constructed, and Router::toResponse() turns whatever the action returns into a response.
