DevPath

Extract business logic from a fat controller

Mid · practical lab · 25 min · runtime php-cli

Brief

A controller method validates input, applies a discount, writes two tables and sends an email. Extract the business logic into a service with one public method, name the dependencies it should receive, and explain what stays in the controller.

3 progressive hints are available in the editor.

Public checks

  • single responsibility — expected: controller delegates business work to a service