Advertisement
gilcierweb

Zend Framework

Dec 15th, 2011
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.01 KB | None | 0 0
  1. http://www.marcosborges.com/blog/tutorial-zend-framework-para-iniciantes/zend-framework-para-iniciantes/zend-framework-para-iniciantes-parte-1/#NameSpace
  2. //Applcation.ini
  3.  
  4.  
  5. [production]
  6.  
  7. includePaths.library = APPLICATION_PATH "/../library"
  8. bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
  9. bootstrap.class = "Bootstrap"
  10. appnamespace = "Application"
  11. resources.frontController.controllerDirectory = APPLICATION_PATH "/Controllers"
  12. resources.layout.layoutPath = APPLICATION_PATH "/Layouts"
  13.  
  14.  
  15.  
  16. ; Database configurations
  17. resources.db.adapter = 'PDO_MYSQL'
  18. resources.db.isDefaultTableAdapter = 'true'
  19. resources.db.params.host = '127.0.0.1'
  20. resources.db.params.username = 'root'
  21. resources.db.params.password = ''
  22. resources.db.params.dbname = 'zendf'
  23. resources.db.params.persistence = 'true'
  24. resources.db.params.charset = "utf8"
  25.  
  26.  
  27. phpSettings.display_startup_errors = 0
  28. phpSettings.display_errors = 0
  29.  
  30. [staging : production]
  31. phpSettings.display_startup_errors = 0
  32. phpSettings.display_errors = 0
  33.  
  34. [testing : production]
  35. phpSettings.display_startup_errors = 1
  36. phpSettings.display_errors = 1
  37.  
  38. [development : production]
  39. phpSettings.display_startup_errors = 1
  40. phpSettings.display_errors = 1
  41.  
  42. ///////////////////////
  43.  
  44. //index.php
  45. <?php
  46. // Definindo algumas constantes
  47. defined('APPLICATION_PATH')
  48.  || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/Application'));
  49. defined('ROOT_PATH')
  50.  || define('ROOT_PATH', realpath(dirname(__FILE__) . '/../'));
  51. defined('PUBLIC_PATH')
  52.  || define('PUBLIC_PATH', realpath(dirname(__FILE__) . '/'));    
  53.  
  54. // Define o nivel da aplicação.
  55. defined('APPLICATION_ENV')
  56.  || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
  57.  
  58. // Aqui são os include paths muito importante configuralos corretamente
  59. set_include_path(implode(PATH_SEPARATOR, array(
  60.  realpath(APPLICATION_PATH), //inclui o diretório da aplicação
  61.  realpath(APPLICATION_PATH . '/../library'), //inclui o diretório da library
  62.  realpath(APPLICATION_PATH . '/Models'), //inclui o diretório dos models dentro das aplications
  63.  get_include_path(), //inclui os demais includes paths já pre definidos
  64. )));
  65.  
  66. /* Zend_Application */
  67. require_once 'Zend/Application.php';
  68. ########## INICIO DOS REQUIRES ################
  69. require_once "Zend/Loader/Autoloader.php";
  70. ########## FINAL DOS REQUIRES ################
  71. try{
  72. /*
  73. Essa predefinição é muito importante pois ela nos permite utilizar um recurso bem legal, não precisamos mais utilizar require, require_once ou include em nossos objetos desde que sigamos uma estrutura de NameSpaces.
  74. Ver mais detalhes em: http://www.marcosborges.com/blog/?page_id=132#NameSpace
  75. */
  76.  $loader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
  77.  // Cria a aplicação, inicia e roda
  78.  $application = new Zend_Application(
  79.  APPLICATION_ENV,
  80.  APPLICATION_PATH . '/Configs/Application.ini'
  81.  );
  82.  $application->bootstrap()
  83.  ->run();
  84. }catch(Exception $e){
  85.  Zend_Debug::dump($e);
  86. }
  87. ?>
  88.  
  89. ///////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement