I have a PHP application running on nginx/php-fpm. In my application, I have a dependency on Sendgrid\Email managed with composer.
On my dev machine everything works fine, composer dependencies are loaded automatically. And all namespaces and classes are found.
When uploading my application to a production environment, I have a piece of PHP code that depends on the Sendgrid package, and suddenly the composer package isn't found (even though it is in my vendor directory, I uploaded everything 1 on 1.
Nginx error log:
2016/08/18 17:40:32 [error] 1022#0: *488 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'SendGrid\Email' not found in <snip>/src/Email/Email.php on line 13" while reading response header from upstream, client: <snip>, server: <snip>, request: "POST /api/<snip> HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "<snip>"
Now the weird thing is, that when I restart my nginx and php-fpm service on my production machine, suddenly the dependency is found without any problems and my code executes. From time to time, my production machine stops finding the nginx dependency, and I have to restart both services to get it working again. (could be only 1, but have always just restarted both)
Output of php -v:
user@productionbox:~$ php -v
PHP 5.5.9-1ubuntu4.19 (cli) (built: Jul 28 2016 19:31:33)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies