简体   繁体   中英

How can I deploy static web app on Heroku

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:

项目结构最初是这个

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM