全部, 我的 PHP Zend MVC 应用程序结构是这样的:
billingsystem
-application
-design
-public
--index.php
--.htaccess
-library
-- Zend
每当应用程序加载时,它都会转到公共(public)文件夹中的 index.php,然后从那里重新路由。我想确保用户可以通过转到 http://billingsystem/ 来访问系统。而不是去 http://billingsystem/public .这是保留公用文件夹的 Zend 约定吗?或者我可以摆脱它并将文件移动到根目录吗?我试过这样做,但我的应用程序失败得很惨,因为它无法找到 Zend 库并加载它的类。我的一些 index.php 代码如下:
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
// Ensure include/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../include'),
get_include_path(),
)));
// Ensure application/models is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../application/models'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
require_once 'Zend/Loader.php';
//Autoload Zend Classes
Zend_Loader::loadClass('Zend_Loader_Autoloader');
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
谢谢
最佳答案
ZF 假定您将主机的文档根目录设置为公用文件夹。这本质上是为了让您的应用程序代码位于“公共(public)”空间之外。如果您使用的是 apache 服务器,则需要修改 httpd.conf (1.x) 或 apache2.conf (2.x) 文件中的 DocumentRoot 指令。您的服务器本身可以有一个 DocumentRoot,您也可以创建每个都有 DocumentRoot 的 VirtualHost。这是一个关于为您的网站设置虚拟主机的不错的教程:http://apptools.com/phptools/virtualhost.php . Zend wiki 中还有一个很好的示例:http://framework.zend.com/wiki/display/ZFDEV/Configuring%2BYour%2BURL%2BRewriter
关于php - Zend MVC - 摆脱公用文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2193236/