简体   繁体   English

Kohana在服务器上找不到模板,但是在localhost上可以正常工作

[英]Kohana can't find template on the server, but it works fine on localhost

I'm working out the kinks in the deployment of my webapp in development, but I've finally hit one I can't figure out on my own. 我正在研究开发中的Web应用程序的部署方式,但是最终我碰到了一个我自己无法解决的问题。

I have a post-commit hook in my svn that deploys all of my commits to a staging site, to ensure nothing breaks before I push to production. 我的svn中有一个提交后钩子,该钩子将我所有的提交都部署到一个暂存站点,以确保在推向生产之前没有任何中断。 Thus, assuming my local working copy has no pending commits, localhost and staging have identical files. 因此,假设我的本地工作副本没有挂起的提交,则本地主机和暂存具有相同的文件。

Right now, my localhost works perfectly fine (the codebase isn't complete, but that's an entirely separate issue). 现在,我的本地主机运行良好(代码库不完整,但这是一个完全独立的问题)。 On my staging site, however, I get the following exception from Kohana framework: 但是,在我的登台站点上,我从Kohana框架得到以下异常:

View_Exception [ 0 ]: The requested view index.tpl could not be found View_Exception [0]:找不到请求的视图index.tpl

If I manually visit the uris for my other controllers, I get the same message, with the template filename substituted. 如果我手动访问其他控制器的uri,则会收到相同的消息,并替换了模板文件名。 Following the stack trace, the error is occurring in the before function of the View factory, when the framework attempts to load my template file -- as expected. 在堆栈跟踪之后,当框架尝试按预期方式加载我的模板文件时,该错误发生在View工厂的before函数中。

My views directory (and all the files contained therein) has the same permissions as all of the other directories in my project, so I'm not sure why PHP wouldn't be able to read the directory or the files. 我的views目录(及其中包含的所有文件)与项目中的所有其他目录具有相同的权限,因此我不确定为什么PHP无法读取目录或文件。 I've also confirmed that the files do in fact exist on the server. 我还确认了文件确实确实存在于服务器上。

My error log shows nothing; 我的错误日志什么也没有显示。 my access log shows a 500 error. 我的访问日志显示500错误。 The Kohana logfile shows the same information that appears on-screen. Kohana日志文件显示的信息与屏幕上显示的信息相同。

I'm genuinely confused as to why this is happening. 我真的很困惑为什么会这样。 The framework is obviously functioning, as I'm getting Kohana's formatted exception and the Kohana log is being written to. 该框架显然正在运行,因为我正在获取Kohana的格式化异常,并且正在写入Kohana日志。 The autoloader is finding my controller classes, because the "missing" file changes appropriately as I visit my various controllers which use different templates. 自动装带器正在查找我的控制器类,因为当我访问使用不同模板的各种控制器时,“缺失”文件会相应更改。 But the server's behavior doesn't match my localhost, and I'm left scratching my head. 但是服务器的行为与我的本地主机不匹配,我被抓挠了。


After looking at Kohana::find_file , the method that's returning false , I came to the conclusion that Kohana was looking for index.tpl.php . 在查看Kohana::find_file (返回false的方法)之后,我得出的结论是Kohana正在寻找index.tpl.php I added some trace debugging to confirm, and I was correct: on my localhost, Kohana is looking for views\\index.tpl while on my server, it's looking for views/index.tpl.php . 我添加了一些跟踪调试来确认,我是正确的:在我的本地主机上,Kohana正在寻找views\\index.tpl而在我的服务器上,它正在寻找views/index.tpl.php However, a second oddity appeared, which may explain the first. 但是,出现了第二个奇怪之处,这可能解释了第一个。 Here is the full list of files that find_file tries to look for when loading up my index page on my local machine and my server: 这是在本地计算机和服务器上加载索引页时find_file尝试查找的文件的完整列表:

LOCAL:                                             SERVER:
classes\I18n.php                                   classes/I18n.php
classes\Kohana\I18n.php                            classes/Kohana/I18n.php
classes\HTTP.php                                   classes/HTTP.php
classes\Kohana\HTTP.php                            classes/Kohana/HTTP.php
classes\Kohana\Exception.php                       classes/Kohana/Exception.php
classes\Kohana\Kohana\Exception.php                classes/Kohana/Kohana/Exception.php
classes\Log.php                                    classes/Log.php
classes\Kohana\Log.php                             classes/Kohana/Log.php
classes\Config.php                                 classes/Config.php
classes\Kohana\Config.php                          classes/Kohana/Config.php
classes\Log\File.php                               classes/Log/File.php
classes\Kohana\Log\File.php                        classes/Kohana/Log/File.php
classes\Log\Writer.php                             classes/Log/Writer.php
classes\Kohana\Log\Writer.php                      classes/Kohana/Log/Writer.php
classes\Config\File.php                            classes/Config/File.php
classes\Kohana\Config\File.php                     classes/Kohana/Config/File.php
classes\Kohana\Config\File\Reader.php              classes/Kohana/Config/File/Reader.php
classes\Kohana\Config\Reader.php                   classes/Kohana/Config/Reader.php
classes\Kohana\Config\Source.php                   classes/Kohana/Config/Source.php
classes\Route.php                                  classes/Route.php
classes\Kohana\Route.php                           classes/Kohana/Route.php
classes\Cookie.php                                 classes/Cookie.php
classes\Kohana\Cookie.php                          classes/Kohana/Cookie.php
classes\Session.php                                classes/Session.php
classes\Kohana\Session.php                         classes/Kohana/Session.php
classes\Request.php                                classes/Request.php
classes\Kohana\Request.php                         classes/Kohana/Request.php
classes\HTTP\Request.php                           classes/HTTP/Request.php
classes\Kohana\HTTP\Request.php                    classes/Kohana/HTTP/Request.php
classes\HTTP\Message.php                           classes/HTTP/Message.php
classes\Kohana\HTTP\Message.php                    classes/Kohana/HTTP/Message.php
classes\HTTP\Header.php                            classes/HTTP/Header.php
classes\Kohana\HTTP\Header.php                     classes/Kohana/HTTP\Header.php
classes\Request\Client\Internal.php                classes/Request/Client/Internal.php
classes\Kohana\Request\Client\Internal.php         classes/Kohana/Request/Client/Internal.php
classes\Request\Client.php                         classes/Request/Client.php
classes\Kohana\Request\Client.php                  classes/Kohana/Request/Client.php
classes\Arr.php                                    classes/Arr.php
classes\Kohana\Arr.php                             classes/Kohana/Arr.php
classes\Response.php                               classes/Response.php
classes\Kohana\Response.php                        classes/Kohana/Response.php
classes\HTTP\Response.php                          classes/HTTP/Response.php
classes\Kohana\HTTP\Response.php                   classes/Kohana/HTTP/Response.php
classes\Profiler.php                               classes/Profiler.php
classes\Kohana\Profiler.php                        classes/Kohana/Profiler.php
classes\Controller\Home.php                        classes/Controller/Home.php
classes\Controller\HFTemplate.php                  classes/Controller/HFTemplate.php
classes\Controller\Template.php                    classes/Controller/Template.php
classes\Kohana\Controller\Template.php             classes/Kohana/Controller/Template.php
classes\Controller.php                             classes/Controller.php
classes\Kohana\Controller.php                      classes/Kohana/Controller.php
classes\View.php                                   classes/View.php
classes\Kohana\View.php                            classes/Kohana/View.php
classes\Smarty\View.php
config\smarty.php
classes\Config\Group.php
classes\Kohana\Config\Group.php
vendor\smarty/libs/Smarty.class.php
classes\URL.php
classes\Kohana\URL.php
classes\Smarty\Helper.php
classes\Kohana\Smarty\Helper.php
views\index.tpl                                    views/index.tpl.php
classes\Auth.php
classes\Kohana\Auth.php
config\auth.php
classes\Auth\ORM.php
classes\Kohana\Auth\ORM.php
config\session.php
classes\Session\Database.php
classes\Kohana\Session\Database.php
classes\Database.php
classes\Kohana\Database.php
config\database.php
classes\Database\PDO.php
classes\Kohana\Database\PDO.php
classes\DB.php
classes\Kohana\DB.php
classes\Database\Query\Builder\Select.php
classes\Kohana\Database\Query\Builder\Select.php
classes\Database\Query\Builder\Where.php
classes\Kohana\Database\Query\Builder\Where.php
classes\Database\Query\Builder.php
classes\Kohana\Database\Query\Builder.php
classes\Database\Query.php
classes\Kohana\Database\Query.php
classes\Database\Result\Cached.php
classes\Kohana\Database\Result\Cached.php
classes\Database\Result.php
classes\Kohana\Database\Result.php
classes\ORM.php
classes\Kohana\ORM.php
classes\Model.php
classes\Kohana\Model.php
classes\Model\User.php
classes\Model\Auth\User.php
classes\Inflector.php
classes\Kohana\Inflector.php
config\inflector.php
classes\UTF8.php
classes\Kohana\UTF8.php
classes\Model\Role.php
classes\Model\Auth\Role.php
                                                   classes/View/Exception.php
                                                   classes/Kohana/View/Exception.php
                                                   classes/Debug.php
                                                   classes/Kohana/Debug.php
                                                   classes/Date.php
                                                   classes/Kohana/Date.php
                                                   views/kohana/error.php
                                                   classes/Text.php
                                                   classes/Kohana/Text.php
(page content)                                     (exception page content)
classes\Database\Query\Builder\Update.php
classes\Kohana\Database\Query\Builder\Update.php

There is a gap where the system ought to be getting the Smarty module classes, but isn't. 系统应该获取Smarty模块类存在差距,但事实并非如此。 After seeing this, I confirmed that the Smarty module does in fact exist on the server and that it's enabled in Kohana's bootstrap. 看到此信息后,我确认服务器上确实存在Smarty模块,并且已在Kohana的引导程序中启用了它。 Yet it isn't being loaded. 但是它尚未被加载。 Any ideas? 有任何想法吗?

As it turns out, the root of the issue was case-sensitivity on Linux. 事实证明,问题的根源是Linux区分大小写。 I arrived at this conclusion with the help of the module author on his GitHub repository . 在模块作者在其GitHub存储库中的帮助下,我得出了这个结论。 I assume he will fix this error in the repository in the near future, however, the fix was changing the names of 4 files: 我认为他将在不久的将来修复存储库中的此错误,但是,此修复正在更改4个文件的名称:

  • MODPATH/smarty/classes/view.php to View.php MODPATH/smarty/classes/view.phpView.php
  • MODPATH/smarty/classes/Smarty/view.php to View.php MODPATH/smarty/classes/Smarty/view.phpView.php
  • MODPATH/smarty/classes/Smarty/helper.php to Helper.php MODPATH/smarty/classes/Smarty/helper.phpHelper.php
  • MODPATH/smarty/classes/Kohana/Smarty/helper.php to Helper.php MODPATH/smarty/classes/Kohana/Smarty/helper.phpHelper.php

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 cURL无法在免费主机中连接,但在我的本地主机上可以正常工作 - cURL can't connect in a free host but works fine in my localhost 会话可以在localhost上正常运行,但不能在Webhost服务器上运行 - Session works fine on localhost, but not on webhost server PHP:Readfile() 在 localhost 但在服务器上工作正常 - PHP: Readfile() works fine at localhost but not at server CodeIgniter邮件无法在服务器上运行,但可以在本地主机上正常工作 - CodeIgniter mail not working on server but works fine localhost 连接到localhost可以正常工作,但是我无法连接到localhost上的大多数子目录。 怎么了? - Connecting to localhost works fine, but I can't connect to most subdirectories on localhost. What's wrong? PHP-提交登录表单后重定向到主页在服务器上不起作用,但在localhost上可以正常工作 - PHP- Redirect to home page after submit login form doesn't work on server but works fine on localhost 为什么Kohana找不到我的变量 - Why can't kohana find my Variable require_once在webserver上找不到文件,但在localhost上工作 - require_once can't find file on webserver but works on localhost Kohana:由于命名约定更改,服务器找不到core.php - Kohana: server can't find core.php because of naming convention change 将Kohana上载到服务器后,无法从其他模块中找到控制器 - Kohana can't find controller from other module when uploaded to the server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM