doudang2817 2013-06-03 15:09
浏览 65
已采纳

使用Git部署时PHP应用程序中断,如果通过sftp部署,则工作正常

I have a simple PHP app that I developed locally in MAMP. I did use a few Composer packages. It works perfectly on my local machine. When I deploy the website using Beanstalk App (not AWS Beanstalk, I'm referring to Beanstalk the Git hosting and deployment service) it throws an error once the first class name is referenced in the code.

Fatal error: Class 'User' not found in /srv/www/example.com/public_html/utilities/authenticate.php on line 8

This class is specific to an ActiveRecord Model class for accessing the database. In the code it looks like this:

$user_row = User::find_by_email($theuser);

Very simple and works in my local development environment. ActiveRecord is autoloaded by Composer.

I then tried deploying the app via sftp to my Centos VPS and to my surprise the error went away and the app works as expected. My best guess was that Beanstalk was somehow corrupting the app during deployment. So to test that theory, I setup a bare Git repo on the server and used a post-receive hook to checkout the repo into the public Apache folder. This resulted in the same error I experienced with Beanstalk. It seems the problem is associated with git deployment. I checked that the files had the standard 644 permissions and that folders are set to 755. Apache owns the public folder so ownership isn't the problem either. I'm truly at a loss for why this is occurring. Any wisdom on the matter is greatly appreciated.

  • 写回答

2条回答 默认 最新

  • duanjing2013 2013-06-03 23:11
    关注

    I've managed to fix the issue. It was a misconfiguration of ActiveRecord on my part. My "User" model class resided in a file named "user.php." That is an incorrect naming convention when using ActiveRecord. Since the class name begins with an uppercase letter so too must the file name. By renaming the file to "User.php" ActiveRecord was able to locate the class correctly. The odd part is that the incorrect naming was not a problem when the documents were placed on the server via sftp. I must assume that there are complexities to the CentOS file system that I don't fully understand. I am aware that unlike CentOS, OS X doesn't have a case sensitive file system and that is the reason why this error never occurred in development.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序