Exemple #1
0
 /**
  * Construct the application
  * 
  * @param array|ArrayAccess Config array/object
  * @return void
  */
 protected function __construct($config)
 {
     // set app namespace
     $this->namespace = trim($config['namespace'], '\\');
     /**
      * Namespace for application resources (e.g. models, controllers, etc.)
      * @var string
      */
     define('APP_NAMESPACE', $this->namespace);
     // Env
     $this->set('env', $env = new Common\Env($config['root']));
     $env->setCharset($config['charset']);
     $env->setTimezone($config['timezone']);
     $env->setDebug($config['debug']);
     $env->setIni($config['ini']);
     foreach ($config['dirs'] as $name => $dir) {
         $env->addDirectory($dir, $name, true);
     }
     $env->configurePHP();
     // class aliaser
     $this->set('aliaser', $aliaser = new Common\ClassAliaser());
     $aliaser->addAliases($config['aliases'])->register();
     // set Config object
     $this->set('config', new \Config($config));
     $autoloader = Common\Autoloader::instance($this->namespace);
     $autoloader->setPath(dirname(APP));
     $autoloader->register();
 }
Exemple #2
0
/**
 * Registers an autoloader for a given namespace and directory.
 * 
 * @param string $namespace Namespace for which to register an autoloader.
 * @param string $path Filesystem directory path that holds classes of given namespace.
 * @return void
 */
function autoloader_register($namespace, $path)
{
    $loader = \Phpf\Common\Autoloader::instance($namespace);
    $loader->setPath($path);
    $loader->register();
}