class ApplicationBuilder

Properties

protected array $pendingProviders

The service providers that are marked for registration.

protected array $additionalRoutingCallbacks

Any additional routing callbacks that should be invoked while registering routes.

Methods

__construct(Application $app)

Create a new application builder instance.

withKernels()

Register the standard kernel classes for the application.

withProviders(array $providers = [], bool $withBootstrapProviders = true)

Register additional service providers.

withEvents(iterable|bool $discover = true)

Register the core event service provider for the application.

withBroadcasting(string $channels, array $attributes = [])

Register the broadcasting services for the application.

withRouting(Closure|null $using = null, array|string|null $web = null, array|string|null $api = null, string|null $commands = null, string|null $channels = null, string|null $health = null, string $apiPrefix = 'api', callable|null $then = null)

Register the routing services for the application.

buildRoutingCallback(array|string|null $web, array|string|null $api, string|null $health, string $apiPrefix, callable|null $then)

Create the routing callback for the application.

withMiddleware(callable|null $callback = null)

Register the global middleware, middleware groups, and middleware aliases for the application.

withCommands(array $commands = [])

Register additional Artisan commands with the application.

withCommandRouting(array $paths)

Register additional Artisan route paths.

withSchedule(callable $callback)

Register the scheduled tasks for the application.

withExceptions(callable|null $using = null)

Register and configure the application's exception handler.

withBindings(array $bindings)

Register an array of container bindings to be bound when the application is booting.

withSingletons(array $singletons)

Register an array of singleton container bindings to be bound when the application is booting.

withScopedSingletons(array $scopedSingletons)

Register an array of scoped singleton container bindings to be bound when the application is booting.

prefersJsonResponses(bool $prefer = true)

Globally prefer JSON responses when the incoming "Accept" header is broad.

registered(callable $callback)

Register a callback to be invoked when the application's service providers are registered.

booting(callable $callback)

Register a callback to be invoked when the application is "booting".

booted(callable $callback)

Register a callback to be invoked when the application is "booted".

create()

Get the application instance.

Details

at line 42
__construct(Application $app)

Create a new application builder instance.

Parameters

Application $app

at line 55
ApplicationBuilder withKernels()

Register the standard kernel classes for the application.

Re-registering the kernels replaces shared bindings and can discard middleware or console configuration used by subsequent requests and commands.

Return Value

ApplicationBuilder

at line 85
ApplicationBuilder withProviders(array $providers = [], bool $withBootstrapProviders = true)

Register additional service providers.

The provider list persists in a static property used when the application registers its providers.

Parameters

array $providers
bool $withBootstrapProviders

Return Value

ApplicationBuilder

at line 107
ApplicationBuilder withEvents(iterable|bool $discover = true)

Register the core event service provider for the application.

The discovery settings persist in static properties, and the provider registers on the application for the worker lifetime.

Parameters

iterable|bool $discover

Return Value

ApplicationBuilder

at line 137
ApplicationBuilder withBroadcasting(string $channels, array $attributes = [])

Register the broadcasting services for the application.

The broadcast routes and channels register on the application for the worker lifetime.

Parameters

string $channels
array $attributes

Return Value

ApplicationBuilder

at line 158
ApplicationBuilder withRouting(Closure|null $using = null, array|string|null $web = null, array|string|null $api = null, string|null $commands = null, string|null $channels = null, string|null $health = null, string $apiPrefix = 'api', callable|null $then = null)

Register the routing services for the application.

The routes and their loading callback persist for the worker lifetime.

Parameters

Closure|null $using
array|string|null $web
array|string|null $api
string|null $commands
string|null $channels
string|null $health
string $apiPrefix
callable|null $then

Return Value

ApplicationBuilder

at line 197
protected Closure buildRoutingCallback(array|string|null $web, array|string|null $api, string|null $health, string $apiPrefix, callable|null $then)

Create the routing callback for the application.

Parameters

array|string|null $web
array|string|null $api
string|null $health
string $apiPrefix
callable|null $then

Return Value

Closure

at line 253
ApplicationBuilder withMiddleware(callable|null $callback = null)

Register the global middleware, middleware groups, and middleware aliases for the application.

The middleware configuration applies to the shared kernels for the worker lifetime.

Parameters

callable|null $callback

Return Value

ApplicationBuilder

at line 302
ApplicationBuilder withCommands(array $commands = [])

Register additional Artisan commands with the application.

The commands register on the shared console kernel for the worker lifetime.

Parameters

array $commands

Return Value

ApplicationBuilder

at line 331
protected ApplicationBuilder withCommandRouting(array $paths)

Register additional Artisan route paths.

The route paths register on the shared console kernel for the worker lifetime.

Parameters

array $paths

Return Value

ApplicationBuilder

at line 349
ApplicationBuilder withSchedule(callable $callback)

Register the scheduled tasks for the application.

The callback persists for the worker lifetime and configures the shared schedule.

Parameters

callable $callback

Return Value

ApplicationBuilder

at line 372
ApplicationBuilder withExceptions(callable|null $using = null)

Register and configure the application's exception handler.

The exception handler binding and resolution callback persist in the application container and affect subsequent requests.

Parameters

callable|null $using

Return Value

ApplicationBuilder

at line 398
ApplicationBuilder withBindings(array $bindings)

Register an array of container bindings to be bound when the application is booting.

The bindings persist on the application for the worker lifetime.

Parameters

array $bindings

Return Value

ApplicationBuilder

at line 415
ApplicationBuilder withSingletons(array $singletons)

Register an array of singleton container bindings to be bound when the application is booting.

The bindings persist on the application for the worker lifetime.

Parameters

array $singletons

Return Value

ApplicationBuilder

at line 436
ApplicationBuilder withScopedSingletons(array $scopedSingletons)

Register an array of scoped singleton container bindings to be bound when the application is booting.

The bindings persist on the application for the worker lifetime.

Parameters

array $scopedSingletons

Return Value

ApplicationBuilder

at line 458
ApplicationBuilder prefersJsonResponses(bool $prefer = true)

Globally prefer JSON responses when the incoming "Accept" header is broad.

The middleware joins the shared kernel's global stack for the worker lifetime.

Parameters

bool $prefer

Return Value

ApplicationBuilder

at line 479
ApplicationBuilder registered(callable $callback)

Register a callback to be invoked when the application's service providers are registered.

The callback persists on the application for the worker lifetime.

Parameters

callable $callback

Return Value

ApplicationBuilder

at line 494
ApplicationBuilder booting(callable $callback)

Register a callback to be invoked when the application is "booting".

The callback persists on the application for the worker lifetime.

Parameters

callable $callback

Return Value

ApplicationBuilder

at line 509
ApplicationBuilder booted(callable $callback)

Register a callback to be invoked when the application is "booted".

The callback persists on the application for the worker lifetime.

Parameters

callable $callback

Return Value

ApplicationBuilder

at line 520
Application create()

Get the application instance.

Return Value

Application