Skip to content

Application booted callbacks called twice #53589

Closed
@simonworkhouse

Description

@simonworkhouse

Laravel Version

11.33.2

PHP Version

8.2.23

Database Driver & Version

SQLite

Description

Booted callbacks are being called twice when they are registered within another booted callback.

Steps To Reproduce

Create a fresh laravel/laravel project and add the following to the register method of App\Providers\AppServiceProvider:

$this->app->booted(function () {
    dump("This only outputs once.");
    $this->app->booted(function () {
        dump("This outputs twice.");
    });
});

Execute php artisan about and it will show the following:

$ php artisan about   
"This only outputs once." // app/Providers/AppServiceProvider.php:15
"This outputs twice." // app/Providers/AppServiceProvider.php:17
"This outputs twice." // app/Providers/AppServiceProvider.php:17
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions