示例#1
0
 /**
  * @param   string  $views
  */
 public function __construct($views = null)
 {
     if ($views !== null) {
         $this->views = $views;
     }
     $this->fileExtension = Config::get('view.extension', '.php');
 }
示例#2
0
 /**
  * @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);
 }
示例#3
0
 /**
  * @param   null|string $name
  *
  * @return  void
  */
 public static function connect($name = null)
 {
     if (is_null($name)) {
         $name = 'default';
     }
     if (is_null(self::$connection)) {
         $config = Config::get('database');
         self::$connection = new Connection($config[$name]);
     }
 }
示例#4
0
 /**
  * @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);
 }
示例#5
0
<?php

use Phphilosophy\Autoloader;
use Phphilosophy\Application\Config;
/*
 * Phphilosophy bootstrap file
 *
 * @author      Lisa Saalfrank <*****@*****.**>
 * @copyright   2015-2016 Lisa Saalfrank
 * @license	    http://opensource.org/licenses/MIT MIT License
 */
// Require the autoload and the config file
require __DIR__ . '/../framework/Autoloader.php';
require __DIR__ . '/../application/configs/application.php';
require __DIR__ . '/../application/configs/database.php';
// create the autoload instance
$autoload = new Autoloader();
// Add namespace prefixes
$autoload->addNamespace('Phphilosophy', __DIR__ . '/../framework/');
$autoload->addNamespace($configs['app.name'] . '\\Model', __DIR__ . '/../application/models/');
$autoload->addNamespace($configs['app.name'] . '\\Guard', __DIR__ . '/../application/guards/');
$autoload->addNamespace($configs['app.name'] . '\\Controller', __DIR__ . '/../application/controllers/');
$autoload->addNamespace($configs['app.name'] . '\\Library', __DIR__ . '/../application/libraries/');
// register the autoloader
$autoload->register();
// Add config values
Config::set('database', $database);
Config::set('app.name', $configs['app.name']);
Config::set('app.view_ext', $configs['app.view_ext']);
示例#6
0
 /**
  * @return  callable
  */
 public function getGuard()
 {
     // Add the namespace prefix for the guard classes to the classname
     $classname = '\\' . Config::get('app.name') . '\\Guard\\' . $this->guard[0];
     return $this->createCallable($classname, $this->guard[1]);
 }
示例#7
0
<?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']);