문제

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

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.

다른 팁

Try to check your .gitignore file. Even better if you paste it's content here. Are you sure you don't need to run composer install on the server after deployment?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top