简体   繁体   English

共享主机上的Cake PHP中缺少Helper文件错误

[英]Missing Helper file error in cake php on shared hosting

I am getting a Missing Helper error when I am trying to upload my cake php files to a shared host. 尝试将蛋糕的php文件上传到共享主机时,出现“缺少帮助程序”错误。

Undefined variable: javascript Missing Helper File 未定义变量:javascript缺少帮助程序文件

It is working fine on my local machine. 在我的本地计算机上运行正常。

I have the following directory structure in shared hosting:(using cpanel) 我在共享托管中具有以下目录结构:(使用cpanel)

/home/user/
   /app
   /cake
   /vendors
  /public _html
    /css
    /img
   /js
   .htaccess
   index.php

I have also made all the relevant changes to the index.php file and I was getting the full colored cake php intro page. 我还对index.php文件进行了所有相关更改,并获得了完整的彩色蛋糕php介绍页。 The strange thing is that it is recognizing the HTML helper and hence i am able to see my web page with full CSS. 奇怪的是,它可以识别HTML帮助器,因此我能够看到具有完整CSS的网页。 However, it is giving problems with javascript and other helpers. 但是,它给javascript和其他帮助程序带来了问题。 I already have an app_controller file with all helpers well defined in $helpers =array(). 我已经有一个app_controller文件,其中所有帮助程序都在$ helpers = array()中定义得很好。

Why is it giving this error?? 为什么会出现此错误?

As mentioned above, I have made changes to my cake directory structure. 如上所述,我对cake目录结构进行了更改。 So, do I have to make changes to the paths.php file located in the cake/config folder?? 因此,我是否必须更改cake / config文件夹中的paths.php文件? I think that cake is not finding the javascript helper because something is messed up with config files. 我认为蛋糕找不到javascript帮助程序,因为配置文件有些混乱。 Is it so or there is some other problem?? 是这样还是有其他问题?

in /app/app_controller.php, add: 在/app/app_controller.php中,添加:

var $helpers = array('Javascript');

your structure doesn't seem like cakephp structure :-( 您的结构似乎不像cakephp结构:-(

Guys, I found a simple way to tackle this problem. 伙计们,我找到了解决此问题的简单方法。 I certainly cannot call it the solution for the problem. 我当然不能称其为问题的解决方案。 May be a temporary way to make things work. 可能是使事情正常工作的临时方法。

I simply replaced 我只是更换了

<?php echo $javascript->link(array('tabulator')); ?>

with the standard HTML, 使用标准HTML,

<script type="text/javascript" src="/blog/js/tabulator.js"></script> 

and it worked!! 而且有效!!

I still don't know the problem with javascript helper. 我仍然不知道javascript helper的问题。 All other helpers, Html, Form and Ajax are working fine. HTML,Form和Ajax等所有其他帮助程序都可以正常工作。 I am also using Gravatar for my blog. 我还在博客上使用Gravatar。 So, the Gravatar Helper was also giving problems. 因此,Gravatar Helper也出现了问题。 The solution to this problem was weird. 解决这个问题的方法很奇怪。 I renamed the helper file gravatar.php instead of Gravatar.php. 我重命名了辅助文件gravatar.php而不是Gravatar.php。 This worked insipte of the fact that helper file name should begin with a capital letter according to cake naming conventions!! 这实际上是一个事实,即根据蛋糕命名约定,助手文件名应以大写字母开头!

I also had to solve numerous other problems like making changes to the index.php file so that cake can locate the modified directory structure. 我还必须解决许多其他问题,例如更改index.php文件,以便Cake可以找到修改后的目录结构。

Also, had to make changes to .htaccess file for rewriting the base and directing the blog to the new URL. 另外,必须对.htaccess文件进行更改,以重写基础并将博客指向新的URL。

Man..so much for rapid development!! 真是太快了。 :O :O

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM