目录结构
模板输出结果!
smarty.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH.'libraries/Smarty/libs/Smarty.class.php');
class CI_Smarty extends Smarty {
public function __construct() {
parent::__construct();
$this->setCompileDir(APPPATH."views/templates_c");
$this->setTemplateDir(APPPATH."views/templates");
$this->setConfigDir(APPPATH.'config/smarty_config');
$this->setCacheDir(APPPATH."cache/smarty_cache");
$this->assign("APPPATH", APPPATH);
if (method_exists($this, 'assignByRef'))
{
$ci =& get_instance();
$this->assignByRef("ci", $ci);
}
$this->force_compile = 1;
$this->caching = true;
$this->cache_lifetime = 120;
log_message('debug',"Smarty initialized!");
}
public function view($template, $return = FALSE) {
if (strpos($template, '.') === FALSE && strpos($template, ':') === FALSE) {
$template .= '.tpl';
}
if ($return==FALSE) {
parent::display($template);
} else {
return parent::fetch($template);
}
}
}
<?php
use Doctrine\Common\ClassLoader,
Doctrine\ORM\Configuration,
Doctrine\ORM\EntityManager,
Doctrine\Common\Cache\ArrayCache,
Doctrine\DBAL\Logging\EchoSqlLogger;
class Doctrine {
public $em = null;
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH.'config/database.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
require_once APPPATH.'libraries/Doctrine/Common/ClassLoader.php';
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH.'libraries');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, '/'));
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH.'models/proxies');
$proxiesClassLoader->register();
// Set up caches
$config = new Configuration;
$cache = new ArrayCache;
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Set up driver
$Doctrine_AnnotationReader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
$Doctrine_AnnotationReader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($Doctrine_AnnotationReader, APPPATH.'models');
$config->setMetadataDriverImpl($driver);
// Proxy configuration
$config->setProxyDir(APPPATH.'/models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
//$logger = new EchoSqlLogger;
//$config->setSqlLogger($logger);
$config->setAutoGenerateProxyClasses( TRUE );
// Database connection information
$connectionOptions = array(
'driver' => 'pdo_mysql',
'user' => $db['default']['username'],
'password' => $db['default']['password'],
'host' => $db['default']['hostname'],
'dbname' => $db['default']['database']
);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
}