use AM\InterventionRequest\ShortUrlExpander;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals();
$log = new Logger('InterventionRequest');
$log->pushHandler(new StreamHandler('interventionRequest.log', Logger::INFO));
/*
 * A test configuration
 */
$conf = new Configuration();
$conf->setCachePath(APP_ROOT . '/cache');
$conf->setImagesPath(APP_ROOT . '/test');
$conf->setJpegoptimPath('/usr/local/bin/jpegoptim');
$conf->setPngquantPath('/usr/local/bin/pngquant');
$conf->setUseFileChecksum(false);
/*
 * Handle short url with Url rewriting
 */
$expander = new ShortUrlExpander($request);
$params = $expander->parsePathInfo();
if (null !== $params) {
    // this will convert rewritten path to request with query params
    $expander->injectParamsToRequest($params['queryString'], $params['filename']);
}
/*
 * Handle main image request
 */
$iRequest = new InterventionRequest($conf, $request, $log);
$iRequest->handle();
$iRequest->getResponse()->send();