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!

8
  • If you haven't searched for the error on the Inernet yet, have a look at (1st) stackoverflow.com/q/44683097/1415724 and the 2nd search result found devcenter.heroku.com/articles/deploying-php - There were more hits, so you might want to continue on from there. Commented Oct 2, 2018 at 1: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. Commented Oct 2, 2018 at 1:43
  • 1
    Can you elaborate "doesn't work good" more? Commented Oct 2, 2018 at 2:12
  • The UI isn't as it is locally. Scrolldown pages don't work Commented Oct 2, 2018 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. Commented Oct 2, 2018 at 13:42

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

6 Comments

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?
Yes, if you go for option 3, then leave the vendor folder as it is, and try to get the minimal composer* files committed.
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.
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).
Finally it worked! Thanks, you spent so much time helping me.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.