Beispiel #1
0
//Using the CLI factory default services container
$di = new CliDI();
// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__)));
/**
 * Register the autoloader and tell it to register the tasks directory
 */
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(APPLICATION_PATH . '/tasks', APPLICATION_PATH . '/models', APPLICATION_PATH . '/library'));
$loader->register();
// Load the configuration file (if any)
if (is_readable(APPLICATION_PATH . '/config/config.php')) {
    $config = (include APPLICATION_PATH . '/config/config.php');
    $di->set('config', $config);
}
$config = $di->get('config');
//Setup the database service
$di->set('db', function () use($config) {
    return new \Phalcon\Db\Adapter\Pdo\Mysql(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->dbname));
});
$di->set('libaccess', function () use($config) {
    return new Mails();
});
/**
 * Loading routes from the routes.php file
 */
// $di->set('router', function() {
// 	return require APPLICATION_PATH . '/config/routers.php';
// });
//Setup the beanstalk service
// $di->set('beanstalk', function() use ($config) {
Beispiel #2
0
     $eventsManager->attach('modelsManager', new FlyAnnotationsInitializer());
     return $modelsManager;
 };
 $di['annotations'] = function () use($config) {
     return new PhAnnotationsAdapter(['annotationsDir' => $config->app_annotations->cache]);
 };
 $di['filemanager'] = function () use($config) {
     $cache = null;
     $filesystem = new FlySystem(new FlyLocalAdapter(ROOT_PATH), $cache);
     return $filesystem;
 };
 $di['lang'] = function () {
     return new \stdClass();
 };
 $di['loggerDB'] = function () use($di) {
     $db = $di->get('db');
     return new PhLoggerDatabase('errors', array('db' => $db, 'table' => 'fly_logs'));
 };
 /**
  * File location constants
  */
 if (!defined('JSON_STRUCTURE')) {
     define('JSON_STRUCTURE', ROOT_PATH . '/migration/structure.json');
 }
 if (!defined('JSON_DATA')) {
     define('JSON_DATA', ROOT_PATH . '/migration/data.json');
 }
 /**
  * CONSOLE APPLICATION
  */
 $console = new PhConsole();