当前位置:Gxlcms > PHP教程 > zendframework一个简单的路径有关问题

zendframework一个简单的路径有关问题

时间:2021-07-01 10:21:17 帮助过:49人阅读

zend framework 一个简单的路径问题
require_once APPLICATION_PATH . '/modules/admin/models/Login.php';这句话,我在controller类里真是用到吐血了,不用不行,找不到model类。
新人求告各位大侠,怎么设置可以不用再加这句话

------解决方案--------------------
zf默认是可以找到model的呀
------解决方案--------------------
为什么要用require_once呢?难道不能用zendframework的自动加载功能。比你这个好多了。
------解决方案--------------------
这是一个最简单的index.php的配置,你参考一下吧
PHP code
  1. <!--?php
  2. // Define path to application directory
  3. defined('APPLICATION_PATH')
  4. || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
  5. // Define application environment
  6. defined('APPLICATION_ENV')
  7. || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
  8. // Ensure library/ is on include_path
  9. set_include_path(implode(PATH_SEPARATOR, array(
  10. realpath(APPLICATION_PATH . '/../library'),
  11. get_include_path(),
  12. )));
  13. /** Zend_Application */
  14. require_once 'Zend/Application.php';
  15. /** Load Layout */
  16. require_once 'Zend/Layout.php';
  17. Zend_Layout::startMvc(array(
  18. 'layoutPath'=-->'../application/layouts',
  19. ));
  20. // Create application, bootstrap, and run
  21. $application = new Zend_Application(
  22. APPLICATION_ENV,
  23. APPLICATION_PATH . '/configs/application.ini'
  24. );
  25. $application->bootstrap()
  26. ->run();

人气教程排行