/** * @access public * @param string $pattern The route pattern * @param array|callable $action The route action * @param array|string $methods The route methods */ public function __construct($pattern, $action, $methods) { $this->config = Config::getInstance(); $this->setPattern($pattern); $this->setAction($action); $this->setMethods($methods); }
/** * @access protected * @return void */ protected function connect() { // Get database config $configs = Config::getInstance(); $config = $configs->get('database'); // Build DSN $dns = 'mysql:host=' . $config['dbhost'] . ';dbname=' . $config['dbname']; // Set options $options = array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $config['dbchar']); // Create new PDO object $this->pdo = new \PDO($dns, $config['dbuser'], $config['dbpass'], $options); }
<?php use Phphilosophy\Autoload\Autoload; use Phphilosophy\Application\Config; /* * Phphilosophy bootstrap file * * @author Lisa Saalfrank <*****@*****.**> * @copyright 2015 PHPhilosophy * @license http://opensource.org/licenses/MIT MIT License */ // Require the autoload and the config file require $_SERVER['DOCUMENT_ROOT'] . '/../framework/Autoload/Autoload.php'; require $_SERVER['DOCUMENT_ROOT'] . '/../application/configs/application.php'; require $_SERVER['DOCUMENT_ROOT'] . '/../application/configs/database.php'; // create the autoload instance $autoload = new Autoload(); // Add namespace prefixes $autoload->add('Phphilosophy', $_SERVER['DOCUMENT_ROOT'] . '/../framework/'); $autoload->add($configs['app.name'] . '\\Model', $_SERVER['DOCUMENT_ROOT'] . '/../application/models/'); $autoload->add($configs['app.name'] . '\\Controller', $_SERVER['DOCUMENT_ROOT'] . '/../application/controllers/'); $autoload->add($configs['app.name'] . '\\Library', $_SERVER['DOCUMENT_ROOT'] . '/../application/libraries/'); // register the autoloader $autoload->register(); // Load project settings $config = Config::getInstance(); // Add config values $config->set('database', $database); $config->set('app.name', $configs['app.name']);