简体   繁体   中英

Application error on heroku - No 'composer.json' found

When I try to access my heroku page it says

"Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details"

This is my build log:

PHP app detected ! WARNING: No 'composer.json' found. Using 'index.php' to declare app type as PHP is considered legacy functionality and may lead to unexpected behavior. Bootstrapping... Installing platform packages... NOTICE: No runtime required in composer.lock; using PHP ^5.5.17 apache (2.4.20) nginx (1.8.1) php (5.6.30) Installing dependencies... Composer version 1.4.1 2017-03-10 09:29:45 Preparing runtime environment... NOTICE: No Procfile, using 'web: heroku-php-apache2'. Checking for additional extensions to install... Discovering process types Procfile declares types -> web Compressing... Done: 13.9M Launching... Released v119 deployed to Heroku Build finished Blogs Careers Documentation

========================================================================

The composer.lock file doesn't just have to exist locally, it has to be committed. That way it will be included when you push to Heroku.

Try something like this:

git add composer.lock
git commit -m "Add Composer lock file"
git push heroku

The reason for this is that composer.json generally specifies dependencies in a somewhat vague way, eg "whatever the latest 1.2.x release is" or "the latest commits on the master branch". You can probably imagine that you and I might get different results depending on when we install our dependencies.

The composer.lock file's job is to lock these dependencies down in a more rigorous way. If you install the latest 1.2.x release of a library, its precise version is recorded in composer.lock, eg "version 1.2.2 at Git hash 1234abc".

In general, unless you are deliberately updating libraries it is better to use composerinstall, not composer update. The former uses the exact versions from the lock file and doesn't update anything. That way we can have more confidence that we are using identical libraries. The latter updates new versions and changes the lock file.

I've never used Heroku with PHP, but it makes sense that it wants to install the exact versions listed in the lock file.

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