Skip to content

Instantly share code, notes, and snippets.

@vexus2
Created October 11, 2012 01:37
Show Gist options
  • Save vexus2/3869620 to your computer and use it in GitHub Desktop.
Save vexus2/3869620 to your computer and use it in GitHub Desktop.
[PHP]ZendFramework用prepare設定 Zend日付バグの対応含む
<?php
if (defined('E_DEPRECATED')) {
error_reporting(E_ALL & ~E_DEPRECATED & ~E_WARNING);
} else {
error_reporting(E_ALL);
}
defined('APPLICATION_CONFIG')
|| define('APPLICATION_CONFIG', 'application.ini');
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
defined('BATCH_APPLICATION_PATH')
|| define('BATCH_APPLICATION_PATH', realpath(dirname(__FILE__) . '/../batch'));
defined('TEST_FILE_PATH')
|| define('TEST_FILE_PATH', realpath(dirname(__FILE__) . '/files'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'local'));
defined('MESSAGE_INI_PATH')
|| define('MESSAGE_INI_PATH', realpath(dirname(__FILE__) . '/../application/configs/messages.ini'));
// タイムゾーン設定
date_default_timezone_set('Asia/Tokyo');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(BATCH_APPLICATION_PATH . '/library'),
realpath(BATCH_APPLICATION_PATH . '/configs'),
realpath(APPLICATION_PATH . '/library'),
realpath(APPLICATION_PATH . '/models'),
realpath(APPLICATION_PATH . '/configs'),
realpath('/usr/local/lib/php'),
realpath('/usr/local/lib/php/PEAR'),
get_include_path(),
)));
require_once 'PHPUnit/Autoload.php';
// ZendFrameworkバグ対応
//ロケール設定(Zend_Date系のロケールがHTTP_HEADERの'Accept-Language'に依存するため)
Zend_Registry::set('Zend_Locale', new Zend_Locale('ja_JP'));
/** Smarty */
require_once APPLICATION_PATH . '/Zend_View_Smarty.class.php';
// コントローラーを設定
$front = Zend_Controller_Front::getInstance();
// アプリケーションフォルダを設定
$front->setControllerDirectory(APPLICATION_PATH . '/controllers');
$view = new Zend_View_Smarty();
$render = new Zend_Controller_Action_Helper_ViewRenderer($view);
// viewRendererヘルパーの設定
$render->setViewSuffix('tpl');
// ヘルパーブローカにViewRendererヘルパーを登録
Zend_Controller_Action_HelperBroker::addHelper($render);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment