0

首先我是新手。我在我的 wamp 服务器中成功安装了 zend 框架。我的包含路径如下:

include_path = ".;E:\wamp\bin\php\zend_framework\library"

我创建了一个项目名称“mehedi”。但是当我浏览到 mehedi/application/ 目录中的 Bootstrap.php 文件时,它显示以下错误:

Fatal error: Class 'Zend_Application_Bootstrap_Bootstrap' not found in E:\wamp`\www\mehedi\application\Bootstrap.php on line 4`

当我浏览到除 mehedi/public/index.php 之外的其他 php 文件时,它会显示一些致命错误。

一切正常还是我错过了一些重要的事情。

这是我的 mehedi/application/configs/application.ini 文件中的应用程序配置:

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
4

1 回答 1

1

如果您使用 Zend_Tool 命令行界面设置您的应用程序,并将.htaccess文件放在公共文件夹中,这是默认设置。
您描述的这种行为是可以预料的。ZF MVC 通过 index.php 文件路由所有请求(图像、css 和 javascript 等资源除外)。因此,如果您可以Bootstrap.php直接路由到您的文件,那么您会担心。

ZF 中的所有 url 都应采用能够www.example.com/moduleName/controllerName/actionName根据需要附加参数的形式。另请注意,这moduleName是可选的,并且将默认为controllerNameif nomoduleName与路由匹配。

要测试您的安装,请使用以下网址:mehedi/public/index/您应该会看到默认的欢迎屏幕。当您添加控制器和操作时,您将自动添加新的 url 路由。

[编辑] 例如,如果您添加一个名为的控制器AdminController(如果您使用 Zend_Tool 添加它,它将自动使用 indexAction() 构建)。您将自动能够AdminController/indexAction使用 url路由到www.mehedi.com/admin/index并且它会起作用。(在大多数应用程序中,索引被指定为默认操作,因此www.mehedi.com/admin会达到相同的结果)

PS 帮自己一个忙,设置一个虚拟主机,它让生活变得更轻松

这是您的虚拟主机可能看起来的示例,如果您打算使用它,将本地主机声明为第一个虚拟主机很重要。

httpd-vhosts.conf  with Include conf/extra/httpd-vhosts.conf enabled in httpd.conf
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    DocumentRoot "C:\Zend\Apache2/htdocs" #I use Zend server, make this match your wamp setup
    ServerName localhost
#directory settings for localhost are typically defined in httpd.conf
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "E:/wamp/www/mehedi/public"
    ServerName www.mehedi.com
    ErrorLog "path/to/your/log/file"
  <directory "E:/wamp/www/mehedi">
      Options Indexes FollowSymlinks
      AllowOverride all
      Order Deny,Allow
      Deny from all
      Allow from 127.0.0.1
  </directory>
</VirtualHost>

重要的是要记住这种虚拟主机设置旨在用于本地开发机器或内部网络服务器,除非您真的知道自己在做什么,否则您不会希望在生产服务器上执行此操作。

于 2012-05-04T13:58:00.883 回答