3

I followed instructions from an answer of a similar topic(https://stackoverflow.com/a/17531897/4388482). Well, my app is getting deployed on Heroku but it doesn't work good. I'm getting the following warning

Your project only contains an 'index.php', no 'composer.json'. Using 'index.php' to declare app type as PHP is deprecated and may lead to unexpected behavior.

Do I need to install something maybe?


UPDATE

Project structure was initially this:

Project structure was initially this

I did the following:

  • Installed PHP 5 and composer.
  • I renamed package.json to composer.json and removed package-lock.json.
  • Typed "composer update" command. I got "nothing to install or update" message.
  • Added vendor to gitignore. Pushed changes to heroku.

I got the following warnings

  1. Your 'composer.lock' is out of date!

  2. Composer vendor dir found in project!

nick
  • 1,611
  • 4
  • 20
  • 35
  • If you haven't searched for the error on the Inernet yet, have a look at (1st) https://stackoverflow.com/q/44683097/1415724 and the 2nd search result found https://devcenter.heroku.com/articles/deploying-php - There were more hits, so you might want to continue on from there. – Funk Forty Niner Oct 02 '18 at 01:17
  • I've done some research. Initially I hadn't installed neither php or composer. I followed heroku instructions and installed them both but still the website doesn't work good. I have php 5, but I that shouldn't be a problem. – nick Oct 02 '18 at 01:43
  • 1
    Can you elaborate "doesn't work good" more? – Yohanes Gultom Oct 02 '18 at 02:12
  • The UI isn't as it is locally. Scrolldown pages don't work – nick Oct 02 '18 at 13:17
  • `package.json` and `package-lock.json` are likely to be JavaScript dependencies. Rename them back to how they were, and don't delete the lock file. You always need the lock file for a repeatable deployment. Are the files in your `vendor` folder committed to the repo? I suspect you need to fix that - remove them from the repo and add a `composer.json` file (and the lock file) to install them using Composer. – halfer Oct 02 '18 at 13:42
  • @halfer composer.json and composer.lock would be empty right? – nick Oct 02 '18 at 13:56
  • I cant find the dependencies. Shouldn't they exist in package.json file? https://github.com/BlackrockDigital/startbootstrap-resume – nick Oct 02 '18 at 14:13
  • I have added an answer below. Would you add your `package.json` contents to your question, in an update at the end? – halfer Oct 02 '18 at 14:31

1 Answers1

4

The complaint that Heroku has is regarding this folder.

For the record, the contents of this folder presently are:

bootstrap
fontawesome-free
jquery-easing
jquery

What has happened here is that someone has committed dependencies to your version control, which is not good practice. It will work as is, but it is not very easy to do upgrades, especially since you cannot easily see what versions you currently do have.

There are three ways to go about this.

  1. Decide if these are PHP dependencies, by searching Packagist. There is a Composer dependency for Bootstrap, but you would need to see if the version you are using is available (or whether you can upgrade to one that is available).

  2. Decide if these are JavaScript dependencies, by searching NPM. I wonder if it is worth examining the contents of your package.json in case these are already covered. For what it is worth, I would generally consider these candidates for JavaScript libraries rather than PHP, but do what works for you.

  3. Choose to leave these dependencies committed in the existing vendor folder. It will work, but it is not ideal for the reasons already stated.

In the last two cases, you could probably get away with a composer.json file thus, which you should commit to the repo:

{
  "require": {
  }
}

You could try a composer install after this, to see if it will generate a .lock file on an empty dependency list. If this does generate, then you should commit this also.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Option 3 would be the best because I don't mind for future upgrades. In that case do I need to commit the vendor folder? – nick Oct 02 '18 at 15:16
  • Yes, if you go for option 3, then leave the `vendor` folder as it is, and try to get the minimal `composer*` files committed. – halfer Oct 02 '18 at 15:21
  • When i type "composer install" I'm getting "Nothing to install or update", and "generating autoload files" messages. Then, on heroku build I'm getting the "composer dir found" warning. – nick Oct 02 '18 at 15:39
  • You may get away without the lock file (since there is nothing to lock). I wonder if there are Heroku settings to turn off the directory error behaviour, since it is not disastrous in itself for a PHP project to have a committed `vendor` folder. If there is no such option, rename `vendor` to anything else (e.g. `myvendors`) and repair all the things in the project that refer to this). – halfer Oct 02 '18 at 15:42
  • Finally it worked! Thanks, you spent so much time helping me. – nick Oct 02 '18 at 16:20
  • Lovely, well done @Antony. If you feel there are any things you learned that would be useful for future readers (e.g. how to turn off errors in Heroku) then you are welcome to add an additional self-answer here. The more information we can create for other people the better. `:=)` – halfer Oct 02 '18 at 16:34