This is very confusing to me. I have built a simple heroku app. It works fine locally. It actually works fine on Heroku IF I push the vendor directory, but then heroku warns me that I should not push the composer vendor directory. The message directs me to a link that instructs me to use composer.lock file for dependencies. So I added a .gitignore to ignore the vendor directory and pushed again, but when I did that, the app doesn't work. I checked the file structure on the heroku remote and it appears dependencies were installed correctly, but the app doesn't work. I'm trying to do this the right way, so I really want this to work, even though I know I can just push my vendor folder and it will work. Has anyone encountered this?
Here is the code from my composer.json file
{
"require": {
"salesforce-mc/fuel-sdk-php": "1.2.2",
"guzzlehttp/guzzle": "~6.0",
"ext-soap": "*",
"php": "7.1.28",
"ext-mcrypt": "*"
}
}
and my Procfile
web: vendor/bin/heroku-php-apache2
The error I get when I try to load the page is pretty generic
This page isn’t working project.herokuapp.com is currently unable to handle this request.
HTTP ERROR 500
Here are the heroku logs
$ heroku logs
2019-04-26T18:14:40.303998+00:00 app[api]: Initial release by user stan_alach@hotmail.com
2019-04-26T18:14:40.888724+00:00 app[api]: Enable Logplex by user stan_alach@hotmail.com
2019-04-26T18:14:40.888724+00:00 app[api]: Release v2 created by user stan_alach@hotmail.com
2019-04-26T18:14:40.303998+00:00 app[api]: Release v1 created by user stan_alach@hotmail.com
2019-04-26T18:15:12.000000+00:00 app[api]: Build started by user stan_alach@hotmail.com
2019-04-26T18:15:21.000000+00:00 app[api]: Build succeeded
2019-04-26T18:15:22.259480+00:00 heroku[web.1]: Starting process with command `vendor/bin/heroku-php-apache2`
2019-04-26T18:15:20.868799+00:00 app[api]: Deploy 1f57bbb2 by user stan_alach@hotmail.com
2019-04-26T18:15:20.868799+00:00 app[api]: Release v3 created by user stan_alach@hotmail.com
2019-04-26T18:15:20.887739+00:00 app[api]: Scaled to web@1:Free by user stan_alach@hotmail.com
2019-04-26T18:15:24.264059+00:00 app[web.1]: Optimizing defaults for 1X dyno...
2019-04-26T18:15:24.284000+00:00 app[web.1]: 4 processes at 128MB memory limit.
2019-04-26T18:15:24.288460+00:00 app[web.1]: Starting php-fpm...
2019-04-26T18:15:26.290267+00:00 app[web.1]: Starting httpd...
2019-04-26T18:15:26.665144+00:00 heroku[web.1]: State changed from starting to up
2019-04-26T18:15:34.496861+00:00 heroku[router]: at=info method=GET path="/" host=cloud-buddy.herokuapp.com request_id=7fa87fe1-fb53-4ef6-ae75-f14488321528 fwd="174.65.133.198" dyno=web.1 connect=0ms service=645ms status=500 bytes=169 protocol=http
2019-04-26T18:15:34.495116+00:00 app[web.1]: [26-Apr-2019 18:15:34 UTC] PHP Fatal error: Uncaught Error: Class 'FuelSdk\SQZL_ET_Client' not found in /app/index.php:18
2019-04-26T18:15:34.495133+00:00 app[web.1]: Stack trace:
2019-04-26T18:15:34.495135+00:00 app[web.1]: #0 {main}
2019-04-26T18:15:34.495201+00:00 app[web.1]: thrown in /app/index.php on line 18
2019-04-26T18:15:34.496655+00:00 app[web.1]: 10.51.197.106 - - [26/Apr/2019:18:15:33 +0000] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36
2019-04-26T18:16:07.874786+00:00 app[api]: Starting process with command `bash` by user stan_alach@hotmail.com
2019-04-26T18:16:10.152678+00:00 heroku[run.9911]: State changed from starting to up
2019-04-26T18:16:10.244363+00:00 heroku[run.9911]: Awaiting client
2019-04-26T18:16:10.279025+00:00 heroku[run.9911]: Starting process with command `bash`
2019-04-26T18:20:32.049330+00:00 heroku[run.9911]: State changed from up to complete
2019-04-26T18:20:32.028902+00:00 heroku[run.9911]: Process exited with status 0
Here is the output I get when I include the vendor folder, and when I do this, the app actually works. I guess for now I'll just let it be, since it's working, but it would be nice to know how to do it the proper way. There must be some sort of file structure issue with the autoload that is not resolving itself when heroku installs the dependencies.
$ git push heroku master
Enumerating objects: 612, done.
Counting objects: 100% (612/612), done.
Delta compression using up to 8 threads
Compressing objects: 100% (595/595), done.
Writing objects: 100% (612/612), 1.08 MiB | 307.00 KiB/s, done.
Total 612 (delta 247), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing platform packages...
remote: - php (7.1.28)
remote: - ext-mcrypt (bundled with php)
remote: - ext-soap (bundled with php)
remote: - apache (2.4.39)
remote: - nginx (1.14.2)
remote:
remote: ! WARNING: Your app's PHP version is no longer actively maintained
remote: !
remote: ! Only security updates will be provided for your PHP version
remote: ! series by the PHP Group until its end-of-life on 2019-12-01.
remote: !
remote: ! It is strongly recommended you update your app to a version of
remote: ! PHP with "active support" status immediately to ensure you get
remote: ! the latest bugfixes and security updates each time you deploy.
remote: !
remote: ! You may check the list of versions supported by the PHP Group
remote: ! and their EOL dates here: http://php.net/supported-versions.php
remote: !
remote: ! For a list of supported runtimes & extensions on Heroku, please
remote: ! refer to: https://devcenter.heroku.com/articles/php-support
remote:
remote: -----> Installing dependencies...
remote: Composer version 1.8.4 2019-02-11 10:52:10
remote:
remote: ! WARNING: Composer vendor dir found in project!
remote: !
remote: ! Your Git repository contains Composer's 'vendor' directory.
remote: !
remote: ! This directory should not be under version control; only your
remote: ! 'composer.json' and 'composer.lock' files need to be added, as
remote: ! Composer will handle installation of dependencies on deploy.
remote: !
remote: ! To suppress this notice, first remove the folder from the index
remote: ! by running 'git rm -r --cached vendor/'.
remote: ! Next, edit your project's '.gitignore' file and add the folder
remote: ! '/vendor/' to the list, then commit the changes.
remote: !
remote: ! For more info, refer to the Composer FAQ:
remote:
remote: Loading composer repositories with package information
remote: Installing dependencies from lock file
remote: Nothing to install or update
remote: Generating optimized autoload files
remote: -----> Preparing runtime environment...
remote: -----> Checking for additional extensions to install...
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 16.2M
remote: -----> Launching...
remote: Released v3
remote: https://cloud-buddy.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/cloud-buddy.git
* [new branch] master -> master