「これからのための気持ちの整理。 」

これからのことを考えています。本当に、本当にめんどうくさい、めんどくさい人間です。これからのために、気持ちの整理をします。

heroku にlaravelをアップロードできない

git push heroku master

久しぶりにherokuにLaravelのソースを上げようとしたときに下記のエラーとなりました。

remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        > @php artisan package:discover --ansi
remote:
remote:        In excel.php line 92:
remote:
remote:          Class 'Maatwebsite\Excel\Excel' not found
remote:
remote:
remote:        Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
remote:  !     WARNING: There was a class not found error in your code
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:  !     - There was a class not found error in your code
remote:

判断が悪かったので時間がかかってしまったのですが(ものすごくテンパってしまい。。)理由はcomposer.json(composer.lock)でした。

www.1x1.jp

よくよくエラーにも出ているのですが、laravel-excel の クラスがrequire-devになっており見つからないとのことでした。

解決方:ライブラリをプロダクションにも必須とするようにcomposer.jsonとcomposer.lockを更新する

composer require maatwebsite/excel
remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        > @php artisan package:discover --ansi
remote:        Discovered Package: fideloper/proxy
remote:        Discovered Package: laravel/tinker
remote:        Discovered Package: maatwebsite/excel
remote:        Discovered Package: nesbot/carbon
remote:        Package manifest generated successfully.
remote: -----> Preparing runtime environment...
remote: -----> Checking for additional extensions to install...
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 25M
remote: -----> Launching...
remote:        Released v18
remote:
remote: Verifying deploy... done.

以上です。