Determining if the Application is Ready for Responses

Problem

You want to know if your application is ready for responses.

Solution

Use the App::readyForResponses() method.

// In a service provider
if (App::readyForResponses())
{
    // Take action when booted
}

Discussion

This is an alias to App::isBooted().

See Checking if the Application is Booted.

Since the application is ready for a response as soon as it's booted, and the application isn't booted until all the service providers are loaded, then any normal code in your application (app/start/global.php, controllers, routes, views) will always return a true result from this method.

The only place that makes sense to call this is in service providers.

comments powered by Disqus