Ejemplo n.º 1
0
<?php

/*
|--------------------------------------------------------------------------
| Create Slim Application
|--------------------------------------------------------------------------
*/
// Instantiate application
$app = new \Slim\Slim(require_once ROOT . '/app/config/app.php');
$app->setName('Active Slim API');
\BurningDiode\Slim\Config\Yaml::_()->addParameters(array('app.mode' => SLIM_MODE, 'app.root' => ROOT, 'app.storage' => ROOT . DIRECTORY_SEPARATOR . 'storage'))->addDirectory(ROOT . '/app/config');
// For native PHP session
session_cache_limiter(false);
session_start();
// For encrypted cookie session
/*
$app->add(new \Slim\Middleware\SessionCookie(array(
            'expires' => '20 minutes',
            'path' => '/',
            'domain' => null,
            'secure' => false,
            'httponly' => false,
            'name' => 'app_session_name',
            'secret' => md5('appsecretkey'),
            'cipher' => MCRYPT_RIJNDAEL_256,
            'cipher_mode' => MCRYPT_MODE_CBC
        )));
*/
/*
|--------------------------------------------------------------------------
| Initialize the database
Ejemplo n.º 2
0
 /**
  * @param $file
  * @return Factory
  * @throws \Exception
  */
 public function addConfigFromYamlFile($file)
 {
     Yaml::getInstance()->addFile($file);
     return self::$instance;
 }
Ejemplo n.º 3
0
    }
}
// Use Mongo's native long int
ini_set('mongo.native_long', 1);
// Only invoked if mode is "production"
$app->configureMode('production', function () use($app, $appRoot) {
    // Add config
    Config\Yaml::getInstance()->addFile($appRoot . '/src/xAPI/Config/Config.production.yml');
    // Set up logging
    $logger = new Logger\MonologWriter(['handlers' => [new StreamHandler($appRoot . '/storage/logs/production.' . date('Y-m-d') . '.log')]]);
    $app->config('log.writer', $logger);
});
// Only invoked if mode is "development"
$app->configureMode('development', function () use($app, $appRoot) {
    // Add config
    Config\Yaml::getInstance()->addFile($appRoot . '/src/xAPI/Config/Config.development.yml');
    // Set up logging
    $logger = new Logger\MonologWriter(['handlers' => [new StreamHandler($appRoot . '/storage/logs/development.' . date('Y-m-d') . '.log')]]);
    $app->config('log.writer', $logger);
});
if (PHP_SAPI !== 'cli') {
    $app->url = Url::createFromServer($_SERVER);
}
// Error handling
$app->error(function (\Exception $e) {
    $code = $e->getCode();
    if ($code < 100) {
        $code = 500;
    }
    Resource::error($code, $e->getMessage());
});