Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yaazel's avatar

Script Illuminate\Foundation\ComposerScripts::postAutoloadDump handling the post-autoload-dump event terminated with Undefined index: HTTP_HOST exception

Hello, I am new to Laravel.

I am trying to install a package using composer require tcg/voyager from the CLI Undefined index: HTTP_HOST exception. I have been having this error with composer dump-autoload also.

I am unable to install any packages. Following suggestions on stackoverflow, I even updated composer by running composer global update. I have no clue what's happening. Please help.

Here is the more detailed log.

composer require tcg/voyager


Using version ^1.4 for tcg/voyager
./composer.json has been updated
Running composer update tcg/voyager
Loading composer repositories with package information
Updating dependencies
Lock file operations: 22 installs, 0 updates, 0 removals
  - Locking arrilot/laravel-widgets (3.13.1)  
  - Locking composer/ca-bundle (1.2.10)       
  - Locking composer/composer (2.1.3)
  - Locking composer/metadata-minifier (1.0.0)
  - Locking composer/semver (3.2.5)
  - Locking composer/spdx-licenses (1.5.5)    
  - Locking composer/xdebug-handler (2.0.1)   
  - Locking doctrine/cache (1.11.3)
  - Locking doctrine/dbal (2.13.1)
  - Locking doctrine/deprecations (v0.5.3)    
  - Locking doctrine/event-manager (1.1.1)    
  - Locking intervention/image (2.5.1)        
  - Locking justinrainbow/json-schema (5.2.10)
  - Locking larapack/doctrine-support (v0.1.9)
  - Locking larapack/hooks (v1.0.12)
  - Locking larapack/voyager-hooks (v1.2.3)
  - Locking laravel/ui (v3.3.0)
  - Locking react/promise (v2.8.0)
  - Locking seld/jsonlint (1.8.3)
  - Locking seld/phar-utils (1.1.1)
  - Locking symfony/filesystem (v5.3.0)
  - Locking tcg/voyager (1.x-dev f24e18b)
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
4 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
Script Illuminate\Foundation\ComposerScripts::postAutoloadDump handling the post-autoload-dump event terminated with an exception

Installation failed, reverting ./composer.json and ./composer.lock to their original content.


  [ErrorException]
  Undefined index: HTTP_HOST  


require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-scripts] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>]...

Here is my composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^7.3|^8.0",
        "anhskohbo/no-captcha": "^3.3",
        "consoletvs/charts": "^7.2",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/cashier": "^12.14",
        "laravel/framework": "^8.40",
        "laravel/socialite": "^5.2",
        "laravel/tinker": "^2.5",
        "laravelcollective/html": "^6.2",
        "maatwebsite/excel": "^3.1",
        "milon/barcode": "^8.0",
        "razorpay/razorpay": "^2.7",
        "shipu/themevel": "^2.2",
        "softon/indipay": "^1.2",
        "yajra/laravel-datatables-oracle": "^9.18"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.6",
        "bennett-treptow/laravel-migration-generator": "^3.1",
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
         "files":[
           "app/constants.php",
           "app/helpers.php",
           "app/language_helper.php"
        ],
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

0 likes
20 replies
bugsysha's avatar

First try updating your composer to the latest version.

yaazel's avatar

I've written in the question that

I even updated composer by running composer global update.

bugsysha's avatar

composer global update will update global packages you have installed, not the composer itself. That is why I suggested to do that first.

yaazel's avatar

Ah! I din't know that. Thank you. I updated composer to latest version 2.1.3

But the error still remains the same.

Snapey's avatar

Show your composer.json

You have something invalid in the "scripts" section of the file

yaazel's avatar

Thanks for your response. I updated my composer.json

yaazel's avatar

No It didn't. You asked me to show composer.json, therefore I updated my question with composer.json. The problem still remains the same.

Snapey's avatar

do you get the same error message with running

php artisan package:discover
yaazel's avatar

No. php artisan package:discover runs successfully.

Discovered Package: anhskohbo/no-captcha
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: bennett-treptow/laravel-migration-generator
Discovered Package: consoletvs/charts
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: intervention/image
Discovered Package: laravel/cashier
Discovered Package: laravel/sail
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravelcollective/html
Discovered Package: maatwebsite/excel
Discovered Package: milon/barcode
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: shipu/themevel
Discovered Package: softon/indipay
Discovered Package: yajra/laravel-datatables-oracle
Package manifest generated successfully.
Snapey's avatar

one thing I would definitely try is deleting the entire vendor folder and then running composer install

yaazel's avatar

Should I also delete composer.lock

Snapey's avatar

you can if you don't mind getting the latest versions of everything

yaazel's avatar

This is what I did.

  1. I ran composer global update
  2. I manually deleted bootstrap/cache/* then
  3. I deleted composer.lock
  4. I deleted entire vendor folder
  5. I ran composer install

It ended with the same error

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
Script Illuminate\Foundation\ComposerScripts::postAutoloadDump handling the post-autoload-dump event terminated with an exception                                                                 ent terminated with an exce


  [ErrorException]
  Undefined index: HTTP_HOST


install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-scripts] [--no-progress] [--no-install] [-v|vv|v--no-suggest] [--no-dev] [-vv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apce-autoloader] [-a|--classmau-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignoreplatform-req IGNORE-PLATFOR-platform-reqs] [--] [<packages>]...

Then I ran php artisan package:discover. It executed successfully`

Then I ran composer require tcg/voyager

Using version ^1.4 for tcg/voyager
./composer.json has been updated
Running composer update tcg/voyager
Loading composer repositories with package information
Updating dependencies
Lock file operations: 22 installs, 0 updates, 0 removals
  - Locking arrilot/laravel-widgets (3.13.1)
  - Locking composer/ca-bundle (1.2.10)
  - Locking composer/composer (2.1.3)
  - Locking composer/metadata-minifier (1.0.0)
  - Locking composer/semver (3.2.5)
  - Locking composer/spdx-licenses (1.5.5)
  - Locking composer/xdebug-handler (2.0.1)
  - Locking doctrine/cache (1.11.3)
  - Locking doctrine/dbal (2.13.1)
  - Locking doctrine/deprecations (v0.5.3)
  - Locking doctrine/event-manager (1.1.1)
  - Locking intervention/image (2.5.1)
  - Locking justinrainbow/json-schema (5.2.10)
  - Locking larapack/doctrine-support (v0.1.9)
  - Locking larapack/hooks (v1.0.12)
  - Locking larapack/voyager-hooks (v1.2.3)
  - Locking laravel/ui (v3.3.0)
  - Locking react/promise (v2.8.0)
  - Locking seld/jsonlint (1.8.3)
  - Locking seld/phar-utils (1.1.1)
  - Locking symfony/filesystem (v5.3.0)
  - Locking tcg/voyager (1.x-dev f24e18b)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 22 installs, 0 updates, 0 removals
  - Installing composer/ca-bundle (1.2.10): Extracting archive
  - Installing composer/metadata-minifier (1.0.0): Extracting archive
  - Installing composer/semver (3.2.5): Extracting archive
  - Installing composer/spdx-licenses (1.5.5): Extracting archive
  - Installing composer/xdebug-handler (2.0.1): Extracting archive
  - Installing doctrine/cache (1.11.3): Extracting archive
  - Installing doctrine/deprecations (v0.5.3): Extracting archive
  - Installing doctrine/event-manager (1.1.1): Extracting archive
  - Installing justinrainbow/json-schema (5.2.10): Extracting archive
  - Installing symfony/filesystem (v5.3.0): Extracting archive
  - Installing seld/phar-utils (1.1.1): Extracting archive
  - Installing seld/jsonlint (1.8.3): Extracting archive
  - Installing react/promise (v2.8.0): Extracting archive
  - Installing composer/composer (2.1.3): Extracting archive
  - Installing larapack/hooks (v1.0.12): Extracting archive
  - Installing laravel/ui (v3.3.0): Extracting archive
  - Installing larapack/voyager-hooks (v1.2.3): Extracting archive
  - Installing doctrine/dbal (2.13.1): Extracting archive
  - Installing larapack/doctrine-support (v0.1.9): Extracting archive
  - Installing intervention/image (2.5.1): Extracting archive
  - Installing arrilot/laravel-widgets (3.13.1): Extracting archive
  - Installing tcg/voyager (1.x-dev f24e18b): Extracting archive
4 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
Script Illuminate\Foundation\ComposerScripts::postAutoloadDump handling the post-autoload-dump event terminated with an exception

Installation failed, reverting ./composer.json and ./composer.lock to their original content.    


  [ErrorException]
  Undefined index: HTTP_HOST  


require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-scripts] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>]...

The changes to ./composer.json and ./composer.lock were reverted back but the vendor folder has the 'tcg/voyager' package folders. I regenerated cache and the cache files have entries related to tcg/voyager. Even the vendor/composer/autoload_static.php and vendor/composer/installed.php have entries related to tcg/voyager.

Running composer why tcg/voyager says:

There is no installed package depending on "tcg/voyager"

What am I to do now? I am just clueless.

Snapey's avatar

When composer runs, it can optionally run scripts provided by the author of the package

    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },

Your install seems to be failing on the line

"Illuminate\Foundation\ComposerScripts::postAutoloadDump",

Which is obviously part of the framework, and probably not an issue with your composer setup

https://github.com/laravel/framework/blob/6a3254ab1796d88a0ce1a1aa4300ba8621ef7175/src/Illuminate/Foundation/ComposerScripts.php#L41

I think the clearCompiled function boots the application, so if you have a fault with your application then this will come out in the composer activity.

Do you get the same error when running any other artisan commands?

Have you added anything to service providers or anything that might be expecting to handle Http requests?

yaazel's avatar

No the artisan commands that I executed so far didn't throw any errors.

I am a beginner. I read the docs, but I don't fully understand what service providers are. I am handing an app which was written by my predecessor. I looked in the app\Providers directory. There aren't any custom made providers in this.

the providers array in config\app.php reads like this:

    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,

        /*
         * Package Service Providers...
         */

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

    ],
Snapey's avatar

ok

look in each of the files in the app/providers folder. They should be mostly empty. You are looking for any attempts to parse the http request

yaazel's avatar

Here is what I did. I created a dummy fresh laravel installation. I compared its app/providers to that of mine. Both the folders had these same 5 files.

	AppServiceProvider.php
	AuthServiceProvider.php
	BroadcastServiceProvider.php
	EventServiceProvider.php
	RouteServiceProvider.php

I individually compared each file and found that all files are are exactly same, except the following lines.

Inside app\Providers\AuthServiceProvider.php of my app, 'App\Models\Model' => 'App\Policies\ModelPolicy', line was extra so I commented it out.

Inside app\Providers\BroadcastServiceProvider.php these were the extra line in my app.

       Broadcast::channel('App.User.*', function ($user, $userId) {
            return (int) $user->id === (int) $userId;
        });

I commented them also out.

I ran composer dump-autoload. I am still getting the same error. I tried clearing cache and reran. The error stills persists.

yaazel's avatar

Hello can someone kindly help me through this. I have been stuck on this and I am unable to install anything using composer.

oirrc_developer's avatar

@yaazel use Illuminate\Support\Str; use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\DB; Use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Auth; Use Illuminate\Support\Facades\Artisan; change your helper.php first lines with this .. it will work. it worked for me.

Please or to participate in this conversation.