execute(); $registry = new Registry; $registry->db = function() use ($registry) { require __DIR__.'/../vendor/PicoDb/Database.php'; switch (DB_DRIVER) { case 'sqlite': require __DIR__.'/Schema/Sqlite.php'; $params = array( 'driver' => 'sqlite', 'filename' => DB_FILENAME ); break; case 'mysql': require __DIR__.'/Schema/Mysql.php'; $params = array( 'driver' => 'mysql', 'hostname' => DB_HOSTNAME, 'username' => DB_USERNAME, 'password' => DB_PASSWORD, 'database' => DB_NAME, 'charset' => 'utf8', ); break; case 'postgres': require __DIR__.'/Schema/Postgres.php'; $params = array( 'driver' => 'postgres', 'hostname' => DB_HOSTNAME, 'username' => DB_USERNAME, 'password' => DB_PASSWORD, 'database' => DB_NAME, ); break; default: die('Database driver not supported'); } $db = new \PicoDb\Database($params); if ($db->schema()->check(Schema\VERSION)) { return $db; } else { die('Unable to migrate database schema!'); } }; $registry->event = function() use ($registry) { return new Event; }; $registry->mailer = function() use ($registry) { require_once 'vendor/swiftmailer/swift_required.php'; switch (MAIL_TRANSPORT) { case 'smtp': $transport = Swift_SmtpTransport::newInstance(MAIL_SMTP_HOSTNAME, MAIL_SMTP_PORT); $transport->setUsername(MAIL_SMTP_USERNAME); $transport->setPassword(MAIL_SMTP_PASSWORD); $transport->setEncryption(MAIL_SMTP_ENCRYPTION); break; case 'sendmail': $transport = Swift_SendmailTransport::newInstance(MAIL_SENDMAIL_COMMAND); break; default: $transport = Swift_MailTransport::newInstance(); } return $transport; };