将 Zend Framework 项目移至 Ubuntu 并且它停止工作
我有一个 Zend Framework 项目,是在 Windows 中开始开发的。它在 Zend Server CE 上运行,一切正常。在 Windows 机器之间移动它完全没有问题。但现在我想把它放在 Ubuntu Server 上,仍然使用 Zend Server CE。但它开始抱怨缺少控制器插件。但它们位于“正确”的位置。我猜自动加载器不知何故变得混乱了。
感觉应该是 Windows 在文件夹和文件上使用不区分大小写的名称造成的。在正确的情况下,Zend Framework 需要有哪些文件夹? 查看标准项目布局使用的文件夹的小写名称。但看看 Zend Framework 本身,首字母都是大写的。 的事实一起
也许与 Zend Framework 自动加载器接受复数表单文件夹名称上的单数类名称(例如位于 forms/Foo.php
中的 Form_Foo
)
在我的项目中,主要部分项目的使用标准小写样式。
即,
application
modules
default
controllers
views
models
forms
plugins
controller
acl
Plugin.php -- The class Plugin_Controller_Acl_Plugin in this file is not found on Linux
foo
controlles
views
models
forms
但是在我的库文件夹中,我有一个 Core 文件夹,其中有我的 Core 类,并且在这些文件夹上我使用 Zend Framework 的方式命名它们
library
Core
Model
User.php -- Contains the class Core_Model_User
。快速测试似乎表明 Zend Framework 能够很好地找到这些类。
在 Linux 中的 Zend Framework 中,您必须在哪里使用正确的大小写名称才能使自动加载工作?如果有人在整个过程中选择第一个大写的名字,
Application
Modules
Default
Controllers
Views
...
欢迎任何想法和提示。
I have a Zend Framework project that I started working on a a while back in Windows. It was run on Zend Server CE and everything worked fine. Moving it between Windows machines was no problem at all. But now I wanted to put it on a Ubuntu Server, still using Zend Server CE. But it started to complain about missing Controller Plugins. But they were located at the "correct" spot. I guess the autoloader is somehow getting confused.
Feels like it should be the fact that Windows uses case-insensitive names on folders and files that be the cause. Which folders does Zend Framework need to have in the correct case?
Looking at standard project layout's lowercase names for folders are used. But looking at the Zend Framework itself capital first letters are used. Maybe together with the fact that the Zend Framework autoloader accepts singular class names on a plural form folder name like
Form_Foo
being located in forms/Foo.php
In my project the main part of the project uses the standard lowercase style.
ie
application
modules
default
controllers
views
models
forms
plugins
controller
acl
Plugin.php -- The class Plugin_Controller_Acl_Plugin in this file is not found on Linux
foo
controlles
views
models
forms
But then in my library folder I have a Core folder where I have my Core classes and on those I use the Zend Framework way of naming them
library
Core
Model
User.php -- Contains the class Core_Model_User
Quick tests seem to indicate that Zend Framework is able to locate these classes just fine.
When in Zend Framework in Linux, where do you have to use correct case names for the autoloading to work? Should one opt for first capital names throughout like
Application
Modules
Default
Controllers
Views
...
Any ideas and tips are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“Plugin_Controller_Acl_Plugin”是唯一无法加载的类吗?如果是这样,您应该尝试对插件内的每个目录(例如plugins/Controller/Acl)使用大写,因为自动加载器仅将命名空间的“Plugin_”部分与“plugins”目录相关联,其他目录将像其他类(保留大写目录名称,仅下划线将转换为目录分隔符)。看一下 Zend_Application_Module_Autoloader 的默认设置,您应该在列出的目录下使用大写目录名称(表单、插件等)。
Is "Plugin_Controller_Acl_Plugin" the only class which cannot be loaded? If so, you should try using uppercase for every directory inside plugins (like plugins/Controller/Acl), because the autoloader only associates the "Plugin_" part of the namespace with the "plugins" directory, the others will be loaded just as the other classes (Uppercase directory names remain, only the underscores will be converted to directory separator). Take a look at Zend_Application_Module_Autoloader for the default settings, you should use uppercase directory names under the directories listed there (forms, plugins, etc.).