【发布时间】:2011-02-23 07:59:55
【问题描述】:
我是 zend 框架的新手,我想了解 bootstrap.php 和 .ini 文件,你能举个例子解释一下吗?
还有数据库示例..
【问题讨论】:
标签: php zend-framework zend-db
我是 zend 框架的新手,我想了解 bootstrap.php 和 .ini 文件,你能举个例子解释一下吗?
还有数据库示例..
【问题讨论】:
标签: php zend-framework zend-db
除了官方ZF quick start,我还可以推荐你看看Tutorial: Getting Started with Zend Framework 1.10。您还可以查看免费书籍:Zend Framework Book: Surviving The Deep End 和 ZendCast。
编辑。应下面 cmets 中 OP 的要求,我粘贴了一些 Bootstrap.php 示例和一个 ini 文件:
Bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
// set a doctype for the Zend_View
protected function _initDoctype() {
$view = $this->bootstrap('view')->getResource('view');
$view->doctype('XHTML1_STRICT');
}
// add path to my view helpers
protected function _initHelperPath() {
$view = $this->bootstrap('view')->getResource('view');
$view->setHelperPath(APPLICATION_PATH . '/views/helpers', 'My_View_Helper');
}
// read appkey.ini and save it to registry for later use
protected function _initAppKeysToRegistry() {
$appkeys = new Zend_Config_Ini(APPLICATION_PATH . '/configs/appkeys.ini');
Zend_Registry::set('keys', $appkeys);
}
}
appkeys.ini
; facebook and twitter app keys obtained after registering your app
; with these two websites.
facebook.appid = YOUR_FACEBOOK_APPID
facebook.secret = YOUR_FACEBOOK_SECRET
facebook.redirecturi = http://url.of.your.app/
facebook.scope = 'email'
twitter.appid = YOUR_TWITTER_APPID
twitter.secret = YOUR_TWITTER_SECRET
twitter.redirecturi = http://url.of.your.app/
【讨论】: