#!/usr/bin/env php
<?php

/**
 * Shell wrapper for Phing
 * $Id: 81628c7f07d7d9326534273f3fdae511e5c1f9d6 $
 */

// turn off html errors
ini_set('html_errors', 'off');

// default logger
if (!in_array('-logger', $argv)) {
    $argv[] = '-logger';
    $argv[] = 'phing.listener.AnsiColorLogger';
}

$files = array(
  __DIR__ . '/../../vendor/autoload.php',
  __DIR__ . '/../../../../autoload.php'
);

foreach ($files as $file) {
    if (file_exists($file)) {
        require $file;

	define('PHING_HOME', dirname($file) . '/phing/phing/');
        define('PHING_COMPOSER_INSTALL', $file);

        break;
    }
}

putenv("PHING_HOME=" . PHING_HOME);

if (!defined('PHING_COMPOSER_INSTALL')) {
    die(
      'You need to set up the project dependencies using the following commands:' . PHP_EOL .
      'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
      'php composer.phar install' . PHP_EOL
    );
}

require_once PHING_HOME . '/bin/phing.php';
