Posted By

nikefido on 12/03/10


Tagged

ini config zend configini


Versions (?)

Sample Zend config.ini file


 / Published in: PHP
 

Same Zend config.ini file with layout, module support, database and custom options. Also some bootstrap code to get custom config items into the systems registry

  1. [production]
  2. ;Error Reporting
  3. phpSettings.display_startup_errors = 0
  4. phpSettings.display_errors = 0
  5.  
  6. ;External Library support
  7. includePaths.library = APPLICATION_PATH "/../library"
  8. autoloaderNamespaces.projname = "ProjName_"
  9.  
  10. ;Bootstrap path
  11. bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
  12. bootstrap.class = "Bootstrap"
  13.  
  14. ;Layout support
  15. resources.layout.layoutPath = APPLICATION_PATH "/views/layouts"
  16. resources.layout.layout = default
  17.  
  18. appnamespace = "Application"
  19. resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
  20. resources.frontController.params.displayExceptions = 0
  21.  
  22. ;Module suport
  23. resources.frontController.params.prefixDefaultModule = "1"
  24. resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
  25. resources.frontController.defaultModule = "default"
  26. resources.modules[] =
  27.  
  28. ;Additional (custom)
  29. facebook.id = ####
  30. facebook.secret = ####
  31. baseUrl = "http://someapp.net"
  32. google.api = "blahblahblah"
  33.  
  34. ;Database (production)
  35. resources.db.adapter = "Pdo_Mysql"
  36. resources.db.params.host = "localhost"
  37. resources.db.params.username = "user"
  38. resources.db.params.password = "pass"
  39. resources.db.params.dbname = "db_name"
  40.  
  41. ;Custom routes
  42. resources.router.routes.connect.route = "app/connect"
  43. resources.router.routes.connect.defaults.controller = "index"
  44. resources.router.routes.connect.defaults.action = "connect"
  45. resources.router.routes.connect.defaults.module = "app"
  46.  
  47. resources.router.routes.article.route = "article/:url_title/*"
  48. resources.router.routes.article.defaults.controller = "index"
  49. resources.router.routes.article.defaults.action = "show"
  50. resources.router.routes.article.defaults.module = "default"
  51. resources.router.routes.article.defaults.url_title = ""
  52. routes.article.reqs.url_title = "\s+"
  53.  
  54. resources.router.routes.flag.route = "flag/:id"
  55. resources.router.routes.flag.defaults.controller = "index"
  56. resources.router.routes.flag.defaults.action = "flag"
  57. resources.router.routes.flag.defaults.module = "default"
  58. resources.router.routes.flag.defaults.id = ""
  59. routes.flag.reqs.id = "\d+"
  60.  
  61. [staging : production]
  62. ;No staging used in this case
  63.  
  64. [testing : production]
  65. ;We want errors in testing
  66. phpSettings.display_startup_errors = 1
  67. phpSettings.display_errors = 1
  68. resources.frontController.params.displayExceptions = 1
  69.  
  70. [development : production]
  71. ;Development - many times localhost
  72. phpSettings.display_startup_errors = 1
  73. phpSettings.display_errors = 1
  74. resources.frontController.params.displayExceptions = 1
  75. baseUrl = "http://localhost:8888/app/public"
  76.  
  77. ;Different params for facebook
  78. facebook.id = #######
  79. facebook.secret = ######
  80.  
  81. ;Database (localhost)
  82. resources.db.adapter = "Pdo_Mysql"
  83. resources.db.params.host = "localhost"
  84. resources.db.params.username = "root"
  85. resources.db.params.password = "root"
  86. resources.db.params.dbname = "localdb_name"
  87.  
  88. <?php
  89. //BONUS - Using boostrap.php to get custom config items
  90. //use Zend_Registry::get('key') anywhere to get the set registry data
  91.  
  92. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
  93. {
  94. protected function _initRegistry() {
  95. Zend_Registry::set('facebook', $this->getOption('facebook'));
  96.  
  97. $googleApi = $this->getOption('google');
  98. Zend_Registry::set('googleApi', $googleApi['api']);
  99. }
  100. }

Report this snippet  

You need to login to post a comment.