#!/usr/bin/env php 
<?php 
/** 
 * PHP version ~5.5 
 * 
 * @category Application 
 * @package  Application 
 * @author   Rafael Ernesto Espinosa Santiesteban <ralphlnx@gmail.com> 
 * @license  MIT <http://www.opensource.org/licenses/mit-license.php> 
 * @link     http://fluency.inc.com 
 */ 
 
if (!defined('BASEPATH')) { 
    define('BASEPATH', realpath(__DIR__ . '/../')); 
} 
 
require_once BASEPATH . '/vendor/autoload.php'; 
 
$app = new \Fluency\Silex\Application(); 
 
// Load configurations 
$app->register( 
    new \Fluency\Silex\Provider\YamlConfigServiceProvider( 
        array( 
            '%base_path%' => BASEPATH, '%log_path%' => BASEPATH . '/var/logs', 
            '%cache_path%' => BASEPATH . '/var/cache' 
        ) 
    ), 
    array( 
        'config.dir' => BASEPATH . '/app/Resources/config', 
        'config.files' => array('console.yml', 'services.yml'), 
    ) 
); 
 
//Set debug option 
$app['debug'] = $app['config']['parameters']['debug']; 
 
//Set Timezone 
if (isset($app['config']['parameters']['timezone'])) { 
    date_default_timezone_set($app['config']['parameters']['timezone']); 
} 
 
// If you don't like this way you can register providers manually. 
foreach ($app['config']['service_providers'] as $serviceProviderConfig) { 
    $app->register( 
        new $serviceProviderConfig['class']( 
            (!isset($serviceProviderConfig['construct_parameters'])) ? 
            null:$serviceProviderConfig['construct_parameters'] 
        ), 
        (isset($serviceProviderConfig['parameters']) 
            && null !== $serviceProviderConfig['parameters'] 
        ) ? 
        $serviceProviderConfig['parameters'] : array() 
    ); 
} 
 
foreach ($app['config']['commands'] as $commandConfig) { 
    $commandInstance = new $commandConfig['class']; 
    $app['console']->add($commandInstance); 
    $app['dispatcher']->dispatch( 
        \Fluency\Silex\Console\Events::COMMAND_LOADED, 
        new \Symfony\Component\Console\Event\ConsoleEvent( 
            $commandInstance, 
            new Symfony\Component\Console\Input\ArrayInput(array()), 
            new Symfony\Component\Console\Output\ConsoleOutput() 
        ) 
    ); 
} 
 
$app['console']->run();
 
 |