Checking if the Application is Booted

Problem

You want to know if your application is booted.

Solution

Use the App::isBooted() method.

// Usually in a service provider
if (App::isBooted())
{
    // Take action when booted
}

Discussion

Booting occurs at a low level.

Your application is "booted" before the request is even dispatched. It is booted before app/start/global.php or app/routes.php or app/filters.php is loaded. (These files are loaded within a "booted" callback.)

Booting the application occurs internally and consists of three steps:

  1. Call any registered "booting" callbacks.
  2. Flag the application as booted.
  3. Call any registered "booted" callbacks.

Therefore, the most likely places you'll use App::isBooted() are within any registered "booting" or "booted" callbacks. Or within a service provider.

comments powered by Disqus