php-cli scripts normally don't have an execution time limit (or a memory limit?), which makes them ideal for upgrades/database maintenance/cron jobs/etc while being able to reuse code from the application itself
one example: https://docs.moodle.org/22/en/Administration_via_command_lin...