在composer.json中需要Helpers文件夹时,将代码部署到heroku时出错

时间:2019-05-05 19:05:46

标签: php laravel laravel-5 heroku

我是heroku的新手,我试图将我的Web应用程序(在本地环境上工作)部署到heroku。我遵循文档,直到步骤:git push heroku master。在heroku安装供应商之后,当生成优化的自动加载文件时,它会显示异常:

Generating optimized autoload files
remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        PHP Warning:  Uncaught ErrorException: require(/tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/../../App/Helpers/functions.php): failed to open stream: No such file or directory in /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php:66
PHP Warning:  Uncaught ErrorException: require(/tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/../../App/Helpers/functions.php): failed to open stream: No such file or directory in /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php:66
remote:        Stack trace:
remote:        #0 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php(66): Composer\Util\ErrorHandler::handle(2, 'require(/tmp/bu...', '/tmp/build_c8be...', 66, Array)
remote:        #1 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php(66): require()
remote:        #2 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php(56): composerRequire52f94ddc173261f270a6e983eeb90c6c('42ab15150aa748b...', '/tmp/build_c8be...')
remote:        #3 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/autoload.php(7): ComposerAutoloaderInit52f94ddc173261f270a6e983eeb90c6c::getLoader()
remote:        #4 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(43): require_once('/tmp/build_c8be...')
remote:        # in /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php on line 66
remote:
remote:        Warning: Uncaught ErrorException: require(/tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/../../App/Helpers/functions.php): failed to open stream: No such file or directory in /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php:66
remote:        Stack trace:
remote:        #0 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php(66): Composer\Util\ErrorHandler::handle(2, 'require(/tmp/bu...', '/tmp/build_c8be...', 66, Array)
remote:        #1 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php(66): require()
remote:        #2 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php(56): composerRequire52f94ddc173261f270a6e983eeb90c6c('42ab15150aa748b...', '/tmp/build_c8be...')
remote:        #3 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/autoload.php(7): ComposerAutoloaderInit52f94ddc173261f270a6e983eeb90c6c::getLoader()
remote:        #4 /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(43): require_once('/tmp/build_c8be...')
remote:        # in /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php on line 66
remote:        PHP Fatal error:  composerRequire52f94ddc173261f270a6e983eeb90c6c(): Failed opening required '/tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/../../App/Helpers/functions.php' (include_path='.:/app/.heroku/php/lib/php') in /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php on line 66
remote:
remote:        Fatal error: composerRequire52f94ddc173261f270a6e983eeb90c6c(): Failed opening required '/tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/../../App/Helpers/functions.php' (include_path='.:/app/.heroku/php/lib/php') in /tmp/build_c8be5dba02b1fb54b907b9b78ea87415/vendor/composer/autoload_real.php on line 66
remote:
remote:  !     ERROR: Dependency installation failed!
remote:  !
remote:  !     The 'composer install' process failed with an error. The cause
remote:  !     may be the download or installation of packages, or a pre- or
remote:  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote:  !     in your 'composer.json'.
remote:  !
remote:  !     Typical error cases are out-of-date or missing parts of code,
remote:  !     timeouts when making external connections, or memory limits.
remote:  !
remote:  !     Check the above error output closely to determine the cause of
remote:  !     the problem, ensure the code you're pushing is functioning
remote:  !     properly, and that all local changes are committed correctly.
remote:  !
remote:  !     For more information on builds for PHP on Heroku, refer to
remote:  !     https://devcenter.heroku.com/articles/php-support
remote:
remote:  !     Push rejected, failed to compile PHP app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to young-oasis-37306.
remote:
To https://git.heroku.com/young-oasis-37306.git

按照它所说的,我认为问题是作曲家找不到在composer.json中定义的App / Helpers文件夹:

    ...
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "files" :[
            "App/Helpers/functions.php"
        ]
    },
    ...
}

但是,因为它可以在本地作曲家中使用,所以我真的不知道如何处理它。你能帮我吗?

Heroku为我选择了平台软件包,以防万一,我会在这里写下。

  • php(7.3.4)

  • ext-mbstring(与php捆绑在一起)

  • Apache(2.4.39)

  • nginx(1.14.2)

1 个答案:

答案 0 :(得分:0)

我想这是在抱怨,因为它在路径'App / Helpers / functions.php'中找不到一个不存在的文件。

尝试将文件更改为实际文件路径。我想看起来像这样:

 "autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/"
    },
    "files" :[
        "./app/Helpers/functions.php"
    ]
},