A simple config file (application / configs / application.ini)
2011-02-16 11:41
363 查看
We will need this configuration file to setup some default values for our application. We will see in the next tutorial how the index.php uses this file and passes its values to the application class to create an instance.
As you can see we have three parts in our configuration file, a config setp for the production environment. Another for the testing environment which inherits the values set for the production mode but changes some values. Finally a setup for the development environment which inherits the values from testing mode (and therefore also from production mode) but also changes some values.
In the php settings part we disable error messages in production mode but enable them for the other environments.
The second part sets the path to our library folder.
The fourth part sets the application directory path and sets the name we want to use for our bootstrap file.
The fifth part liste the modules we will add to our application, i will use those values in different parts of my application, more about this in one of my next tutorials.
In the sixth part we set some values for the frontcontroller. We will put our modules in a folder called "modules" and we will use homepage as name for our main (default) module. The name of the default controller will be "index" and the default action will have the name "index". The next value tells zend framework to use a prefix for the default module. By default zend framework allows you to ommit the prefix for the files in the default module folder. I set this value to true because there are so much things you have to explain to somebody that is new to zend framework, that's why i prefer not having to explain which module is the default one and that only for this module you should not use a prefix. I set throw exceptions to false, because i dont want exceptions to popup as soon as they get thrown. If you set throwExceptions to true the try / catch in our index file will handle the error. I want to use the error controller that we will build during one of the next tutorials. In the last key / value pair we set the application environment we have set in the htaccess and defined in the index.php so that zend framework can pass it to the frontcontroller.
The last part is for website "myapp" specific values, right now we only need one value, the default title for the title tag in our html pages.
Those are all the values we want to use for our production environment, our testing and development environments will inherit those values, but we will also override some of them.
We will add lots more value / pair later in other tutorials but right now its already more then enough to get started.
As you can see we have three parts in our configuration file, a config setp for the production environment. Another for the testing environment which inherits the values set for the production mode but changes some values. Finally a setup for the development environment which inherits the values from testing mode (and therefore also from production mode) but also changes some values.
In the php settings part we disable error messages in production mode but enable them for the other environments.
The second part sets the path to our library folder.
The fourth part sets the application directory path and sets the name we want to use for our bootstrap file.
The fifth part liste the modules we will add to our application, i will use those values in different parts of my application, more about this in one of my next tutorials.
In the sixth part we set some values for the frontcontroller. We will put our modules in a folder called "modules" and we will use homepage as name for our main (default) module. The name of the default controller will be "index" and the default action will have the name "index". The next value tells zend framework to use a prefix for the default module. By default zend framework allows you to ommit the prefix for the files in the default module folder. I set this value to true because there are so much things you have to explain to somebody that is new to zend framework, that's why i prefer not having to explain which module is the default one and that only for this module you should not use a prefix. I set throw exceptions to false, because i dont want exceptions to popup as soon as they get thrown. If you set throwExceptions to true the try / catch in our index file will handle the error. I want to use the error controller that we will build during one of the next tutorials. In the last key / value pair we set the application environment we have set in the htaccess and defined in the index.php so that zend framework can pass it to the frontcontroller.
The last part is for website "myapp" specific values, right now we only need one value, the default title for the title tag in our html pages.
Those are all the values we want to use for our production environment, our testing and development environments will inherit those values, but we will also override some of them.
We will add lots more value / pair later in other tutorials but right now its already more then enough to get started.
[production] ; PHP SETTINGS phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 phpSettings.date.timezone = "Europe/Luxembourg" ; ZEND LIBRARY PATH includePaths.library = APPLICATION_PATH "/../library" ; BOOTSTRAP bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" ; MODULES SETUP resources.modules = Homepage, Admin, Users, News ; RESOURCES ; FrontController resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" ; Layout resources.layout.layoutpath = APPLICATION_PATH "/layouts/scripts" ; Application resources.frontcontroller.moduledirectory = APPLICATION_PATH "/modules" resources.frontcontroller.defaultmodule = "homepage" resources.frontController.defaultControllerName = "index" resources.frontController.defaultAction = "index" resources.frontcontroller.params.prefixDefaultModule = true resources.frontcontroller.throwexceptions = false resources.frontController.env = APPLICATION_ENVIRONMENT ; MY APP website.title = myapp website.default.language = en [testing : production] ; PHP SETTINGS phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] ; PHP SETTINGS phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1
相关文章推荐
- A simple config file (application / configs / application.ini)
- 虚拟机黑屏,日志文件vmware显示DictionaryLoad: Cannot open file "C:\Users\weihy\AppData\Roaming\VMware\config.ini
- Corrupted applicationHost.config file in IIS 7
- eclipse启动错误 Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
- linux sh : get ini config file's section key's value
- [Python]解析.ini 文件出错ConfigParser.MissingSectionHeaderError: File contains no section headers.
- 配置mongodb出现Error parsing INI config file: unrecognised option 'nohttpinterface' 报错
- EF Migrations error: No connection string named 'MpDb' could be found in the application config file.
- [Refereces]Creating an .ini File for the Application Manager
- 解答:一个perl操作config.ini的出现的 cannot find file or dirctionary,可明明文件存在
- applicationHost.config - Configuration file is not well-formed XML
- 不修改“我的文档”的语言情况下,解决“Weird, the AVD's config.ini file is malformated.”异常
- include/config.h:5:22: error: configs/.h: No such file or directory
- [ GIT ] GIT tip : A simple .gitconfig file
- emulator: ERROR: no search paths found in this AVD's configuration. Weird, the AVD's config.ini file
- How to: Reading an ini config file from a batch file
- Corrupted applicationHost.config file in IIS 7
- MySQL无法重启问题解决Warning: World-writable config file ‘/etc/my.cnf’ is ignored
- Qt5 Application:no such file or directory
- Delphi TIniFile 类 操作ini配置文件