Search code examples
phplaravelheroku

When Deploying a Laravel project on Heroku, I got errors


I am new to heroku and got these errors when I tried to deploy my Laravel app. I added web: vendor/bin/heroku-php-apache2 public/ on the procfile too.

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        Deprecation Notice: Return type ofIlluminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Container/Container.php:1231
remote:        Deprecation Notice: Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Container/Container.php:1242
remote:        Deprecation Notice: Return type of Illuminate\Container\Container::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Container/Container.php:1254
remote:        Deprecation Notice: Return type of Illuminate\Container\Container::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Container/Container.php:1267
remote:        > @php artisan package:discover --ansi
remote:        PHP Deprecated:  Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1231
remote:        PHP Deprecated:  Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1242
remote:        PHP Deprecated:  Return type of Illuminate\Container\Container::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1254
remote:        PHP Deprecated:  Return type of Illuminate\Container\Container::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1267
remote:        PHP Deprecated:  Return type of Illuminate\Config\Repository::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 141
remote:        PHP Deprecated:  Return type of Illuminate\Config\Repository::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 152
remote:        PHP Deprecated:  Return type of Illuminate\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 164
remote:        PHP Deprecated:  Return type of Illuminate\Config\Repository::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 175
remote:        PHP Fatal error:  During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1277
remote:        Stack trace:
remote:        #0 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Support/Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
remote:        #1 /tmp/build_275de9ef/vendor/composer/ClassLoader.php(571): include('...')
remote:        #2 /tmp/build_275de9ef/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
remote:        #3 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Support/helpers.php(109): Composer\Autoload\ClassLoader->loadClass()
remote:        #4 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(130): collect()
remote:        #5 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(106): Illuminate\Foundation\PackageManifest->build()
remote:        #6 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(89): Illuminate\Foundation\PackageManifest->getManifest()
remote:        #7 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(78): Illuminate\Foundation\PackageManifest->config()
remote:        #8 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php(26): Illuminate\Foundation\PackageManifest->aliases()
remote:        #9 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(219): Illuminate\Foundation\Bootstrap\RegisterFacades->bootstrap()
remote:        #10 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(320): Illuminate\Foundation\Application->bootstrapWith()
remote:        #11 /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Foundation\Console\Kernel->bootstrap()
remote:        #12 /tmp/build_275de9ef/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
remote:        #13 {main} in /tmp/build_275de9ef/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 11
remote:        Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
remote:  !     WARNING: A post-autoload-dump 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-autoload-dump script terminated with an error
remote: 
remote:  !     Push rejected, failed to compile PHP app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to qutesapp.
remote: 
To https://git.heroku.com/qutesapp.git
 ! [remote rejected]   master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/qutesapp.git'

But, this app is working well on my local machine. I think it is a problem related to composer update... Can anyone help me please?


Solution

  • In my experience, this is due to attempting to run Laravel 7 (or earlier) under PHP 8.1. try to change PHP versions