当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Config_Ini::asArray方法代码示例

本文整理汇总了PHP中Zend_Config_Ini::asArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Config_Ini::asArray方法的具体用法?PHP Zend_Config_Ini::asArray怎么用?PHP Zend_Config_Ini::asArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Config_Ini的用法示例。


在下文中一共展示了Zend_Config_Ini::asArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bootstrap

 public static function bootstrap($installDir)
 {
     if (self::testEnvironment() === false) {
         echo 'Environment fails to meet minimum requirements for this demo tutorial.';
         return;
     }
     // where to find this application's configuration (using Conventional Modular Layout)
     $ds = DIRECTORY_SEPARATOR;
     // too much typing ;)
     if ($installDir[0] === '/') {
         $tmp = $installDir;
     } else {
         $tmp = dirname(__FILE__) . $ds . '..' . $ds . '..' . $ds . 'zfdemo' . $ds . $installDir;
     }
     // STAGE 0: Initializations / Loading Configuration
     ZFDemo_Log::log("looking for application directory in: realpath({$tmp}" . $ds . ')');
     $appDir = realpath($tmp) . $ds;
     ZFDemo_Log::log('$appDir =' . $appDir);
     self::$registry = Zend_Registry::getInstance();
     self::$registry['appDir'] = $appDir;
     if (!is_readable($appDir)) {
         ZFDemo_Log::log("ERROR: Application directory is not readable (path problem).\n", true);
         return false;
     }
     // this application's configuration information
     $configDir = realpath($appDir . $ds . 'config' . $ds) . $ds;
     self::$registry['configDir'] = $configDir;
     ZFDemo_Log::log('$configDir =' . $configDir);
     if (!is_readable($configDir)) {
         ZFDemo_Log::log("ERROR: Application configuration directory 'config' is not readable (path problem).\n", true);
         return false;
     }
     // persistent dynamic data, like log files or SQLite files
     $dataDir = realpath($appDir . $ds . 'data' . $ds) . $ds;
     self::$registry['dataDir'] = $dataDir;
     ZFDemo_Log::log('$dataDir =' . $dataDir);
     if (!is_readable("{$dataDir}")) {
         ZFDemo_Log::log("ERROR: Application 'data' directory is not readable (path problem).\n", true);
         return false;
     }
     // temporary data, like PHP session state files
     $temporaryDir = realpath($appDir . $ds . 'temporary' . $ds) . $ds;
     self::$registry['temporaryDir'] = $temporaryDir;
     ZFDemo_Log::log('$temporaryDir =' . $temporaryDir);
     if (!is_readable("{$temporaryDir}")) {
         ZFDemo_Log::log("ERROR: Application 'temporary' directory is not readable (path problem).\n", true);
         return false;
     }
     // add the application-specific source file path to PHP's include path for the Conventional Modular Layout
     set_include_path($appDir . PATH_SEPARATOR . get_include_path());
     ZFDemo_Log::log("PHP Include Path = \n    " . str_replace(':', "\n    ", ini_get('include_path')));
     self::$environment = 'sandbox';
     // after this point, all defaults come from config files
     require 'Zend/Config/Ini.php';
     $config = new Zend_Config_Ini($configDir . 'config.ini', self::$environment, true);
     ZFDemo_Log::log("config.ini=" . print_r($config->asArray(), true));
     if (strpos($config->log, '/') !== 0) {
         $config->log = $dataDir . $config->log;
     }
     self::$registry['config'] = $config;
     // application configuration array
     date_default_timezone_set($config->timezone);
     $sessionConfig = new Zend_Config_Ini($configDir . 'Zend_Session.ini', self::$environment, true);
     $sessionConfig->save_path = $temporaryDir . $sessionConfig->save_path;
     ZFDemo_Log::log("Zend_Session.ini=" . print_r($sessionConfig->asArray(), true));
     require 'Zend/Session.php';
     Zend_Session::setOptions($sessionConfig->asArray());
     Zend_Session::start();
     /*
      * The zfdemo will not work unless the following code results creates a session file
      * in your save_path folder, * with file contents like:
      *    foo|a:2:{s:3:"bar";s:5:"apple";s:4:"time";s:19:"2007-02-20 21:30:36";}
      */
     $testSpace = new Zend_Session_Namespace('spaceFoo');
     $testSpace->keyBar = 'valueBar';
     $testSpace->time = time();
     $testSpace->date = date('Y-m-d H:i:s');
     // preemptively write session file now
     Zend_Session::writeClose();
     self::testPdo($config);
     // sanity check connection and zfdemo tables using PDO
     // Now test using ZF's MySQL PDO DB adapter:
     require 'Zend/Db.php';
     require 'Zend/Db/Adapter/Pdo/Mysql.php';
     // setup our DB adapter
     $db = new Zend_Db_Adapter_Pdo_Mysql($config->db->asArray());
     self::$registry['db'] = $db;
     self::testDb($db);
     // sanity check connection and zfdemo tables using Zend Db Adapter
     // STAGE 1: Prepare the front (primary) controller.
     require 'Zend/Controller/Front.php';
     $frontController = Zend_Controller_Front::getInstance();
     // manages the overall workflow
     $baseUrl = substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], '/index.php'));
     ZFDemo_Log::log("baseUrl={$baseUrl}");
     //$frontController->setBaseUrl($baseUrl);
     $frontController->setControllerDirectory(array('default' => $appDir . 'default' . $ds . 'controllers', 'forum' => $appDir . 'forum' . $ds . 'controllers'));
     // Initialize views
     require 'Zend/View.php';
     self::$view = new Zend_View();
//.........这里部分代码省略.........
开发者ID:jorgenils,项目名称:zend-framework,代码行数:101,代码来源:index.php


注:本文中的Zend_Config_Ini::asArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。