$_SESSION['slim.flash'] = ''; } /*****************************************************************/ // LOAD THE FRAMEWORK /*****************************************************************/ require VENDORS_PATH . '/Slim/Slim.php'; \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(array('mode' => 'development')); include_once VENDORS_PATH . '/autoload.php'; include_once CONFIGS_PATH . '/database.php'; include_once CONFIGS_PATH . '/application.php'; // CREATE ALIAS FOR FACADE class_alias('Cartalyst\\Sentry\\Facades\\Native\\Sentry', 'Sentry'); // Setup our database $dsn = DRIVER . ":dbname=" . DBNAME . ";host=" . DBHOST; Sentry::setupDatabaseResolver(new PDO($dsn, DBUSER, DBPASS)); // ELOQUENT ORM $settings = array('driver' => DRIVER, 'host' => DBHOST, 'database' => DBNAME, 'username' => DBUSER, 'password' => DBPASS, 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => ''); // OBJECT MAPPER $container = new \Illuminate\Container\Container(); $connFactory = new \Illuminate\Database\Connectors\ConnectionFactory($container); $conn = $connFactory->make($settings); $resolver = new \Illuminate\Database\ConnectionResolver(); $resolver->addConnection('default', $conn); $resolver->setDefaultConnection('default'); \Illuminate\Database\Eloquent\Model::setConnectionResolver($resolver); // AUTOLOADERS include_once dirname(__FILE__) . '/autoloader.php'; AutoLoader::registerDirectory(dirname(__FILE__) . '/models'); AutoLoader::registerDirectory(dirname(__FILE__) . '/classes'); // ROUTE FILES
/** * Boot up Eloquent */ use Illuminate\Database\Capsule\Manager as Capsule; $app->hook('slim.before', function () use($app, $config) { try { $app->container->singleton('db', function () { return new Capsule(); }); $app->db->addConnection($config['database']); $app->db->setAsGlobal(); $app->db->bootEloquent(); /** * Setting up Sentry */ Sentry::setupDatabaseResolver($app->db->connection()->getPdo()); } catch (PDOException $e) { if (file_exists(PUBLIC_PATH . 'install.php') && !defined('INSTALL')) { /** * In case app can not connect to the database and install script was found, redirect to install script * we assume that application is not configured yet */ $publicPath = dirname($_SERVER['SCRIPT_NAME']) . '/'; $installPath = Request::getUrl() . $publicPath . 'install.php'; Response::redirect($installPath); } else { /** * If install script can not be found, re throw the exception to be handled by Slim */ throw $e; }