首页 > 解决方案 > 为尝试转换传递的无效字符,这些已被忽略 - 将 Laravel 项目推送到 heroku

问题描述

我正在尝试从服务器获取一个 laravel 项目并按照所有提供的步骤将其移动到 heroku,当将 repo 推送到 heroku 时,我遇到以下错误:

 Compiling common classes
remote:        
remote:
remote:          [ErrorException]
remote:          Invalid characters passed for attempted conversion, these have been ignored

我一直在查看一个说明此错误的 Guthub 问题 - [PHP 7.4 RC3] 为尝试转换传递的无效字符,这些已被忽略 #2003 - 这是我能找到的少数答案之一。但是,我的项目(vendor/dompdf/dompdf/lib/Cpdf.php)中不存在此问题引用的文件。

error_reporting(E_ALL ^ E_DEPRECATED);其中一个答案建议通过添加到引发错误的文件来关闭错误报告。知道把那条线放在哪里吗?

我看不到错误被抛出的文件。见消息:

      Script php artisan optimize handling the post-install-cmd event returned with error code 1
remote:  !     WARNING: A post-install-cmd script terminated with an error
remote:
remote:  !     ERROR: Dependency installation failed!

我可能正在做一些明显错误的事情。按照以下步骤进行迁移:在 Heroku 上部署 Laravel 项目

编辑:也按照这个问题printing-preview-doesnt-working-laravel-dompdfcomposer update的回答中的建议进行了尝试

编辑2:下面是构建日志:

  Package mtdowling/cron-expression is abandoned, you should avoid using it. Use dragonmantank/cron-expression instead.
remote:        Generating optimized autoload files
remote:        Carbon 1 is deprecated, see how to migrate to Carbon 2.
remote:        https://carbon.nesbot.com/docs/#api-carbon-2
remote:            You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.
remote:        1 package you are using is looking for funding.
remote:        Use the `composer fund` command to find out more!
remote:        > Illuminate\Foundation\ComposerScripts::postInstall
remote:        > php artisan optimize
remote:        Generating optimized class loader
remote:        Compiling common classes
remote:        
remote:
remote:          [ErrorException]
remote:          Invalid characters passed for attempted conversion, these have been ignored
remote:
remote:
remote:        Script php artisan optimize handling the post-install-cmd event returned with error code 1
remote:  !     WARNING: A post-install-cmd script terminated with an error
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:  !     REMINDER: the following warnings were emitted during the build;
remote:  !     check the details above, as they may be related to this error:
remote:  !     - A post-install-cmd script terminated with an error

我试过更新mtdowling/cron-expression包 - 但它一直在恢复它。这或 Carbon 错误是否会导致“无效字符错误”?

标签: phplaravelheroku

解决方案


升级dompdf/dompdf到版本0.8.5将解决这个问题:https ://github.com/dompdf/dompdf/releases

可以通过以下方式安装最新版本:

composer require dompdf/dompdf

composer.json手动修改0.8.5并运行:

composer install

请记住,此升级可能包含重大更改


推荐阅读