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 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图