To decide whether my script is run from CLI I simply create a PHP script that handles only CLI invocations.
File cron.php:
<?php
// Set environment variables your application depends on
$_SERVER[ 'HTTP_HOST' ] = 'domain.tld';
// $_SERVER[ 'REQUEST_URI' ] = '/some/URI/if/needed';
// Use the environment to read out required values
$task = $_SERVER[ 'argv' ][ 1 ];
// Instanciate the dispatcher or whatever you use
$dispatcher = new Dispatcher();
$dispatcher->handle( $task );
?>
This way my application doesn't have to know about CLI at all.