Skip to content

Instantly share code, notes, and snippets.

@UndergroundLabs
Created November 2, 2015 15:15
Show Gist options
  • Save UndergroundLabs/c3b3fc0190e0b5a0e73d to your computer and use it in GitHub Desktop.
Save UndergroundLabs/c3b3fc0190e0b5a0e73d to your computer and use it in GitHub Desktop.
<?php
session_start();
define('ROOT_PATH', __DIR__ . '/../');
define('VENDOR_PATH', __DIR__ . '/../QuizApp/vendor/');
define('CONFIG_PATH', __DIR__ . '/../QuizApp/config/');
define('CONTROLLERS_PATH', __DIR__ . '/../controllers/');
define('TEMPLATE_PATH', __DIR__ . '/../QuizApp/temlates/');
define('APP_PATH', __DIR__ . '/../QuizApp/');
define('PUBLIC_PATH', __DIR__ . '/../www/');
define('LOG_PATH', __DIR__ . '/../logs/');
require VENDOR_PATH . 'autoload.php';
/*
* Create the Slim application
*/
$app = new \Slim\Slim();
/*
* Setup Pimple for dependancy injection
*/
$container = new \Pimple\Container();
$container['app'] = $app;
/*
* Load default configuration
*/
$app->config(require(CONFIG_PATH . 'default.php'));
/*
* Load configuration for development mode
*/
$app->configureMode('development', function() use ($app){
$app->config(require(CONFIG_PATH . 'development.php'));
});
/*
* Load configuration for production mode
*/
$app->configureMode('production', function () use ($app) {
$app->config(require(CONFIG_PATH . 'production.php'));
});
/*
* Configure database
*/
ORM::configure('mysql:host=' . $app->config('db_host') . ';dbname=' . $app->config('db_name'));
ORM::configure('username', $app->config('db_username'));
ORM::configure('password', $app->config('db_password'));
/*
* Setup containers
*/
$container['db'] = function ($container) {
echo 'Database Created!';
};
$app->get('/', function() use ($app, $container) {
echo $container['db'];
});
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment