class Application extends Container implements Application, CachesConfiguration, CachesRoutes

Traits

Constants

protected MAX_RESOLUTION_DEPTH

Maximum resolution depth before assuming a circular dependency.

Safety net for indirect cycles (e.g., through interfaces) where the abstract names differ from the concretes pushed by build(), making the direct in_array check insufficient.

VERSION

The Hypervel framework version.

Properties

static protected Container|null $instance

The current globally available container (if any).

from  Container
static protected int $contextKeyPrefixCount

The number of context key prefixes given to containers in this worker.

from  Container
protected bool[] $resolved

An array of the types that have been resolved.

from  Container
protected array[] $bindings

The container's bindings.

from  Container
protected Closure[] $methodBindings

The container's method bindings.

from  Container
protected array<string, mixed> $instances

The container's shared instances.

from  Container
protected object[] $autoSingletons

Auto-singletoned instances for unbound concrete classes.

from  Container
protected SharedResolution> $sharedResolutions

Cacheable first resolutions currently owned by a coroutine.

from  Container
protected array<int, int> $sharedResolutionWaits

Container waits keyed by the waiting coroutine ID.

from  Container
protected array<string, true> $scopedInstances

The abstract names registered as scoped bindings.

from  Container
protected string|null $contextKeyPrefix

The prefix of this container's coroutine context keys.

from  Container
protected string[] $aliases

The registered type aliases.

from  Container
protected array[] $abstractAliases

The registered aliases keyed by the abstract name.

from  Container
protected array[] $extenders

The extension closures for services.

from  Container
protected array[] $tags

All of the registered tags.

from  Container
array[] $contextual

The contextual binding map.

from  Container
array[] $contextualAttributes

The contextual attribute handlers.

from  Container
protected array<class-string, true> $checkedForAttributeBindings

Whether an abstract class has already had its attributes checked for bindings.

from  Container
protected array<class-string, null|"scoped"|"singleton"> $checkedForSingletonOrScopedAttributes

Whether a class has already been checked for Singleton or Scoped attributes.

from  Container
protected array[] $reboundCallbacks

All of the registered rebound callbacks.

from  Container
protected Closure[] $globalBeforeResolvingCallbacks

All of the global before resolving callbacks.

from  Container
protected Closure[] $globalResolvingCallbacks

All of the global resolving callbacks.

from  Container
protected Closure[] $globalAfterResolvingCallbacks

All of the global after resolving callbacks.

from  Container
protected array[] $beforeResolvingCallbacks

All of the before resolving callbacks by class type.

from  Container
protected array[] $resolvingCallbacks

All of the resolving callbacks by class type.

from  Container
protected array[] $afterResolvingCallbacks

All of the after resolving callbacks by class type.

from  Container
protected Closure>> $afterResolvingAttributeCallbacks

All of the after resolving attribute callbacks by class type.

from  Container
protected null|callable(array<int, string>|string): bool|string $environmentResolver

The callback used to determine the container's environment.

from  Container
static protected BuildRecipe> $buildRecipes

Cache of computed build recipes.

from  Container
static protected array $macros

The registered string macros.

from  Macroable
protected string|null $basePath

The base path for the Hypervel installation.

protected string $bootstrapPath

The path to the bootstrap directory.

protected string|null $storagePath

The custom storage path defined by the developer.

protected string|null $appPath

The custom application "app" path defined by the developer.

protected string|null $configPath

The custom configuration path defined by the developer.

protected string|null $databasePath

The custom database path defined by the developer.

protected string|null $langPath

The custom language file path defined by the developer.

protected string|null $publicPath

The custom public path defined by the developer.

protected string|null $environmentPath

The custom environment path defined by the developer.

protected string|null $environmentFile

The environment file to load during bootstrapping.

protected string[] $absoluteCachePathPrefixes

The prefixes that indicate an absolute cache path.

protected bool $mergeFrameworkConfiguration

Indicates if the framework's base configuration should be merged.

static protected ApplicationBuilder> $applicationBuilder

The application builder class.

protected bool $hasBeenBootstrapped

Indicates if the application has been bootstrapped before.

protected bool|null $isRunningInConsole

Indicates if the application is running in the console.

protected bool $booted

Indicates if the application has "booted".

protected callable[] $bootingCallbacks

The array of booting callbacks.

protected callable[] $bootedCallbacks

The array of booted callbacks.

protected array<callable|string> $terminatingCallbacks

The array of terminating callbacks.

protected callable[] $registeredCallbacks

The array of registered callbacks.

protected ServiceProvider> $serviceProviders

All of the registered service providers.

protected array $loadedProviders

The names of the loaded service providers.

protected string|null $namespace

The application namespace.

Methods

string
firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

array
firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

array
closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

array
closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

when(string|array $concrete)

Define a contextual binding.

void
whenHasAttribute(string $attribute, Closure $handler)

Define a contextual binding based on an attribute.

bool
bound(string $abstract)

Determine if the given abstract type has been bound.

bool
has(string $id)

Determine if the given abstract type has been bound.

bool
resolved(string $abstract)

Determine if the given abstract type has been resolved.

bool
isShared(string $abstract)

Determine if a given type is shared.

bool
isExplicitlyShared(string $abstract)

Determine if a given type has an explicit shared lifetime.

bool
isScoped(string $abstract)

Determine if a given abstract is a scoped binding.

bool
isScopedInstance(mixed $instance)

Determine if the object is a resolved scoped instance in this coroutine.

bool
resolvedScoped(string $abstract)

Determine if a scoped binding has already been resolved in this coroutine.

bool
resolvedShared(string $abstract)

Determine if the container holds a worker-shared instance for the given type.

string|null
getScopedType(ReflectionClass|string $reflection)

Determine if a ReflectionClass has scoping attributes applied.

bool
isAlias(string $name)

Determine if a given string is an alias.

void
bind(Closure|string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding with the container.

void
registerBinding(string $abstract, Closure|string|null $concrete, bool $shared, bool $scoped)

Register one binding and its lifecycle.

getClosure(string $abstract, string $concrete)

Get the Closure to be used when building a type.

bool
hasMethodBinding(string $method)

Determine if the container has a method binding.

void
bindMethod(array|string $method, Closure $callback)

Bind a callback to resolve with Container::call.

string
parseBindMethod(array|string $method)

Get the method to be bound in class@method format.

mixed
callMethodBinding(string $method, mixed $instance)

Get the method binding for the given method.

void
addContextualBinding(string $concrete, string $abstract, mixed $implementation)

Add a contextual binding to the container.

void
bindIf(Closure|string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding if it hasn't already been registered.

void
singleton(Closure|string $abstract, Closure|string|null $concrete = null)

Register a shared binding in the container.

void
singletonIf(Closure|string $abstract, Closure|string|null $concrete = null)

Register a shared binding if it hasn't already been registered.

void
scoped(Closure|string $abstract, Closure|string|null $concrete = null)

Register a scoped binding in the container.

void
scopedIf(Closure|string $abstract, Closure|string|null $concrete = null)

Register a scoped binding if it hasn't already been registered.

void
bindBasedOnClosureReturnTypes(Closure $abstract, Closure|string|null $concrete = null, bool $shared = false, bool $scoped = false, bool $onlyIfUnbound = false)

Register a binding with the container based on the given Closure's return types.

void
extend(string $abstract, Closure $closure)

"Extend" an abstract type in the container.

mixed
instance(string $abstract, mixed $instance)

Register an existing instance as shared in the container.

void
removeAbstractAlias(string $searched)

Remove an alias from the contextual binding alias cache.

void
tag(array|string $abstracts, array|string $tags)

Assign a set of tags to a given binding.

iterable
tagged(string $tag)

Resolve all of the bindings for a given tag.

void
alias(string $abstract, string $alias)

Alias a type to a different name.

mixed
rebinding(string $abstract, Closure $callback)

Bind a new callback to an abstract's rebind event.

mixed
refresh(string $abstract, mixed $target, string $method)

Refresh an instance on the given target and method.

void
rebound(string $abstract)

Fire the "rebound" callbacks for the given abstract type.

array
getReboundCallbacks(string $abstract)

Get the rebound callbacks for a given type.

wrap(Closure $callback, array $parameters = [])

Wrap the given closure such that its dependencies will be injected when executed.

mixed
call(callable|string $callback, array $parameters = [], string|null $defaultMethod = null)

Call the given Closure / class@method and inject its dependencies.

string|false
getClassForCallable(callable|string $callback)

Get the class name for the given callback, if one can be determined.

factory(string $abstract)

Get a closure to resolve the given type from the container.

mixed
makeWith(string $abstract, array $parameters = [])

An alias function name for make().

mixed
make(string $abstract, array $parameters = [])

Resolve the given type from the container.

mixed
makeTransient(string $abstract)

Resolve the given type with a transient implicit lifetime.

mixed
get(string $id)

No description

mixed
resolve(string $abstract, array $parameters = [], bool $raiseEvents = true, bool $transient = false)

Resolve the given type from the container.

bool
shouldCoordinateSharedResolution(string $abstract, mixed $concrete, bool $needsContextualBuild, bool $raiseEvents)

Determine whether this miss can publish a worker-shared instance.

mixed
awaitSharedResolution(string $abstract, SharedResolution $resolution)

Wait for a shared resolution without introducing a coordinator cycle.

bool
sharedResolutionOwnerIsAncestor(int $ownerId, int $coroutineId)

Determine whether the resolution owner is an ancestor of a coroutine.

bool
sharedResolutionWaitWouldCycle(int $waiterId, int $ownerId)

Determine whether adding a container wait edge would close a cycle.

mixed
getConcrete(string $abstract)

Get the concrete type for a given abstract.

mixed
getConcreteBindingFromAttributes(string $abstract)

Get the concrete binding for an abstract from the BindWhen or Bind attributes.

string|null
resolveConcreteFromAttributes(ReflectionClass $reflected)

Resolve the concrete from the Bind and BindWhen attributes in declaration order.

mixed
getContextualConcrete(string $abstract)

Get the contextual concrete binding for the given abstract.

getResolutionState()

Get the resolution state for the current coroutine.

getOrCreateResolutionState()

Get or create the mutable resolution state for the current coroutine.

string
contextKey(string $name)

Get this container's coroutine context key for the given entry.

array
currentBuildStack()

Get the current build stack without creating resolution state.

mixed
findInContextualBindings(string $abstract)

Find the concrete binding for the given abstract in the contextual binding array.

bool
isBuildable(mixed $concrete, string $abstract)

Determine if the given concrete is buildable.

getBuildRecipe(string $concrete)

Get the cached build recipe for the given concrete class.

computeBuildRecipe(string $concrete)

Compute the build recipe for the given concrete class.

mixed
buildWith(Closure|string $concrete, array $parameters = [])

Instantiate a concrete instance with the given parameter overrides.

array
resolveContextualParameters(string $concrete, array|null $names = null)

Resolve the contextual constructor parameters of a class within its build context.

mixed
build(Closure|string $concrete)

Instantiate a concrete instance of the given type.

mixed
buildForResolution(Closure|string $concrete, ContainerResolutionState $resolutionState)

Build a concrete as part of container resolution.

mixed
buildSelfBuildingInstance(string $concrete, BuildRecipe $recipe, ContainerResolutionState $resolutionState)

Instantiate a concrete instance of the given self building type.

array
resolveRecipeParameters(BuildRecipe $recipe, ContainerResolutionState $resolutionState)

Resolve all constructor parameters using cached recipe metadata.

mixed
resolvePrimitive(ParameterRecipe $param)

Resolve a non-class hinted primitive dependency.

mixed
resolveClass(ParameterRecipe $param)

Resolve a class based dependency from the container.

mixed
resolveVariadicClass(ParameterRecipe $param)

Resolve a class based variadic dependency from the container.

mixed
resolveFromAttribute(ReflectionAttribute $attribute, ReflectionParameter $parameter)

Resolve a dependency based on an attribute.

never
notInstantiable(string $concrete)

Throw an exception that the concrete is not instantiable.

never
unresolvablePrimitive(ParameterRecipe $param)

Throw an exception for an unresolvable primitive.

void
beforeResolving(Closure|string $abstract, Closure|null $callback = null)

Register a new before resolving callback for all types.

void
resolving(Closure|string $abstract, Closure|null $callback = null)

Register a new resolving callback.

void
afterResolving(Closure|string $abstract, Closure|null $callback = null)

Register a new after resolving callback for all types.

void
afterResolvingAttribute(string $attribute, Closure $callback)

Register a new after resolving attribute callback for all types.

void
fireBeforeResolvingCallbacks(string $abstract, array $parameters = [])

Fire all of the before resolving callbacks.

void
fireBeforeCallbackArray(string $abstract, array $parameters, array $callbacks)

Fire an array of callbacks with an object.

void
fireResolvingCallbacks(string $abstract, mixed $object)

Fire all of the resolving callbacks.

void
fireAfterResolvingCallbacks(string $abstract, mixed $object)

Fire all of the after resolving callbacks.

void
fireAfterResolvingAttributeCallbacks(array $attributes, mixed $object)

Fire all of the after resolving attribute callbacks.

void
fireCallbacksForType(string $abstract, mixed $object, array $callbacksPerType)

Fire all callbacks that match the given abstract or object type.

void
fireCallbackArray(mixed $object, array $callbacks)

Fire an array of callbacks with an object.

int|string|null
currentlyResolving()

Get the class name or closure object ID the container is currently resolving.

array
getBindings()

Get the container's bindings.

string
getAlias(string $abstract)

Get the alias for an abstract if available.

array
getExtenders(string $abstract)

Get the extender callbacks for a given type.

void
forgetExtenders(string $abstract)

Remove all of the extender callbacks for a given type.

void
dropStaleInstances(string $abstract)

Drop all of the stale instances and aliases.

void
forgetCachedInstances(string $abstract)

Forget every cached instance for an abstract without changing its lifecycle.

void
forgetInstance(string $abstract)

Remove a resolved instance from the instance cache.

void
forgetInstances()

Clear all of the instances from the container.

void
forgetScopedInstances()

Clear all of the scoped instances from the container.

void
resolveEnvironmentUsing(callable|null $callback)

Set the callback which determines the current container environment.

bool
currentEnvironmentIs(array|string $environments)

Determine the environment for the container.

void
flush()

Flush the container of all bindings and resolved instances.

void
__clone()

Give the cloned container its own coroutine context entries.

static Container
getInstance()

Get the globally available instance of the container.

static Container|null
setInstance(Container|null $container = null)

Set the shared instance of the container.

static void
flushState()

Flush all static state.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

__construct(string|null $basePath = null)

No description

void
checkEnvironment()

Check that the runtime environment is properly configured.

configure(string|null $basePath = null)

Configure and create a new application builder instance.

static string
inferBasePath()

Infer the application's base directory from the environment.

string
version()

Get the version number of the application.

void
registerBaseBindings()

Register the basic bindings into the container.

void
registerBaseServiceProviders()

Register all of the base service providers.

void
bootstrapWith(array $bootstrappers)

Run the given array of bootstrap classes.

void
beforeBootstrapping(string $bootstrapper, Closure $callback)

Register a callback to run before a bootstrapper.

void
afterBootstrapping(string $bootstrapper, Closure $callback)

Register a callback to run after a bootstrapper.

void
afterLoadingEnvironment(Closure $callback)

Register a callback to run after loading the environment.

bool
hasBeenBootstrapped()

Determine if the application has been bootstrapped before.

setBasePath(string $basePath)

Set the base path for the application.

void
bindPathsInContainer()

Bind all of the application paths in the container.

string
path(string $path = '')

Get the path to the application "app" directory.

useAppPath(string $path)

Set the application directory.

string
basePath(string $path = '')

Get the base path of the Hypervel installation.

string
bootstrapPath(string $path = '')

Get the path to the bootstrap directory.

useBootstrapPath(string $path)

Set the bootstrap file directory.

string
getBootstrapProvidersPath()

Get the path to the service provider list in the bootstrap directory.

string
configPath(string $path = '')

Get the path to the application configuration files.

useConfigPath(string $path)

Set the configuration directory.

string
databasePath(string $path = '')

Get the path to the database directory.

useDatabasePath(string $path)

Set the database directory.

string
langPath(string $path = '')

Get the path to the language files.

useLangPath(string $path)

Set the language file directory.

string
publicPath(string $path = '')

Get the path to the public directory.

usePublicPath(string $path)

Set the public / web directory.

string
resourcePath(string $path = '')

Get the path to the resources directory.

string
viewPath(string $path = '')

Get the path to the views directory.

string
storagePath(string $path = '')

Get the path to the storage directory.

useStoragePath(string $path)

Set the storage directory.

string|null
environmentPath()

Get the path to the environment file directory.

useEnvironmentPath(string $path)

Set the directory for the environment file.

loadEnvironmentFrom(string $file)

Set the environment file to be loaded during bootstrapping.

string
environmentFile()

Get the environment file the application is using.

string
environmentFilePath()

Get the fully-qualified path to the environment file.

bool
configurationIsCached()

Determine if the application configuration is cached.

string
getCachedConfigPath()

Get the path to the configuration cache file.

string
getCachedPackagesPath()

Get the path to the cached packages.php file.

bool
routesAreCached()

Determine if the application routes are cached.

string
getCachedRoutesPath()

Get the path to the routes cache file.

bool
eventsAreCached()

Determine if the application events are cached.

string
getCachedEventsPath()

Get the path to the events cache file.

string
normalizeCachePath(string $key, string $default)

Normalize a relative or absolute path to a cache file.

addAbsoluteCachePathPrefix(string $prefix)

Add new prefix to list of absolute path prefixes.

string
joinPaths(string|null $basePath, string $path = '')

Join the given paths together.

bool|string
environment(UnitEnum|array|string ...$environments)

Get or check the current application environment.

bool
isLocal()

Determine if the application is in the local environment.

bool
isProduction()

Determine if the application is in the production environment.

string
detectEnvironment(Closure $callback)

Detect the application's current environment.

bool
runningInConsole()

Determine if the application is running in the console.

bool
runningConsoleCommand(string|array ...$commands)

Determine if the application is running any of the given console commands.

void
setRunningInConsole(bool $runningInConsole)

Set whether the application is running in the console.

bool
runningUnitTests()

Determine if the application is running unit tests.

bool
hasDebugModeEnabled()

Determine if the application is running with debug mode enabled.

maintenanceMode()

Get an instance of the maintenance mode manager implementation.

bool
isDownForMaintenance()

Determine if the application is currently down for maintenance.

int
handleCommand(InputInterface $input)

Handle the incoming Artisan command.

bool
shouldMergeFrameworkConfiguration()

Determine if the framework's base configuration should be merged.

dontMergeFrameworkConfiguration()

Indicate that the framework's base configuration should not be merged.

bool
shouldSkipMiddleware()

Determine if middleware has been disabled for the application.

void
registered(callable $callback)

Register a new registered listener.

void
registerConfiguredProviders()

Register all of the configured providers.

array
discoverProviders()

Discover service providers from installed composer packages.

static array
sortByPriority(array $providers)

Sort providers by their priority property in descending order.

register(ServiceProvider|string $provider, bool $force = false)

Register a service provider with the application.

getProvider(ServiceProvider|string $provider)

Get the registered service provider instance if it exists.

array
getProviders(ServiceProvider|string $provider)

Get the registered service provider instances if any exist.

resolveProvider(string $provider)

Resolve a service provider instance from the class name.

void
markAsRegistered(ServiceProvider $provider)

Mark the given provider as registered.

bool
isBooted()

Determine if the application has booted.

void
boot()

Boot the application's service providers.

void
bootProvider(ServiceProvider $provider)

Boot the given service provider.

void
booting(callable $callback)

Register a new boot listener.

void
booted(callable $callback)

Register a new "booted" listener.

terminating(callable|string $callback)

Register a terminating callback with the application.

void
terminate()

Terminate the application.

void
fireAppCallbacks(array $callbacks)

Call the booting callbacks for the application.

never
abort(int $code, string $message = '', array $headers = [])

Throw an HttpException with the given data.

array
getLoadedProviders()

Get the service providers that have been loaded.

bool
providerIsLoaded(string $provider)

Determine if the given service provider is loaded.

string
getLocale()

Get the current application locale.

bool
isLocale(string $locale)

Determine if the application locale is the given locale.

string
currentLocale()

Get the current application locale.

string
getFallbackLocale()

Get the current application fallback locale.

void
setLocale(string $locale)

Set the current application locale.

void
setFallbackLocale(string $fallbackLocale)

Set the current application fallback locale.

void
registerCoreContainerAliases()

Register the core class aliases in the container.

string
getNamespace()

Get the application namespace.

Details

in ReflectsClosures at line 26
protected string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

Parameters

Closure $closure

Return Value

string

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 49
protected array firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 75
protected array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

in ReflectsClosures at line 97
protected array closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

in Container at line 272
ContextualBindingBuilder when(string|array $concrete)

Define a contextual binding.

Parameters

string|array $concrete

Return Value

ContextualBindingBuilder

in Container at line 286
void whenHasAttribute(string $attribute, Closure $handler)

Define a contextual binding based on an attribute.

Parameters

string $attribute
Closure $handler

Return Value

void

in Container at line 294
bool bound(string $abstract)

Determine if the given abstract type has been bound.

Parameters

string $abstract

Return Value

bool

at line 328
bool has(string $id)

Determine if the given abstract type has been bound.

The facade system calls has() before get() to check if a service is resolvable. With auto-singleton semantics, any concrete class can be resolved, so has() must return true for existing classes.

Parameters

string $id

Return Value

bool

in Container at line 310
bool resolved(string $abstract)

Determine if the given abstract type has been resolved.

Parameters

string $abstract

Return Value

bool

in Container at line 324
bool isShared(string $abstract)

Determine if a given type is shared.

Parameters

string $abstract

Return Value

bool

in Container at line 346
protected bool isExplicitlyShared(string $abstract)

Determine if a given type has an explicit shared lifetime.

Parameters

string $abstract

Return Value

bool

in Container at line 372
bool isScoped(string $abstract)

Determine if a given abstract is a scoped binding.

Parameters

string $abstract

Return Value

bool

in Container at line 403
bool isScopedInstance(mixed $instance)

Determine if the object is a resolved scoped instance in this coroutine.

Parameters

mixed $instance

Return Value

bool

in Container at line 434
bool resolvedScoped(string $abstract)

Determine if a scoped binding has already been resolved in this coroutine.

Scoped instances live in coroutine-local context, so this is false at the start of every request even for a binding resolved many times before. Callers that would only inspect an instance can use this to avoid paying for a full resolution — and the construction it implies — when nothing in the request asked for one.

Only the scoped resolution path writes this context key, so its presence already implies the binding is scoped; singletons, auto-singletons and transient bindings never produce one. An instance() registration that replaced a scoped binding also counts: it supersedes the scoped lifetime during resolution — tests swap scoped services this way — so an existing instance must be reported as resolved rather than skipped.

Parameters

string $abstract

Return Value

bool

in Container at line 446
bool resolvedShared(string $abstract)

Determine if the container holds a worker-shared instance for the given type.

Parameters

string $abstract

Return Value

bool

in Container at line 461
protected string|null getScopedType(ReflectionClass|string $reflection)

Determine if a ReflectionClass has scoping attributes applied.

Parameters

ReflectionClass|string $reflection

Return Value

string|null

in Container at line 507
bool isAlias(string $name)

Determine if a given string is an alias.

Parameters

string $name

Return Value

bool

in Container at line 521
void bind(Closure|string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding with the container.

Bindings persist on the worker-lifetime container; runtime use races across coroutines and changes resolution for every subsequent request.

Parameters

Closure|string $abstract
Closure|string|null $concrete
bool $shared

Return Value

void

Exceptions

TypeError
ReflectionException

in Container at line 540
protected void registerBinding(string $abstract, Closure|string|null $concrete, bool $shared, bool $scoped)

Register one binding and its lifecycle.

Parameters

string $abstract
Closure|string|null $concrete
bool $shared
bool $scoped

Return Value

void

in Container at line 577
protected Closure getClosure(string $abstract, string $concrete)

Get the Closure to be used when building a type.

Parameters

string $abstract
string $concrete

Return Value

Closure

in Container at line 598
bool hasMethodBinding(string $method)

Determine if the container has a method binding.

Parameters

string $method

Return Value

bool

in Container at line 609
void bindMethod(array|string $method, Closure $callback)

Bind a callback to resolve with Container::call.

Method bindings persist on the worker-lifetime container and affect every subsequent Container::call() for the bound method.

Parameters

array|string $method
Closure $callback

Return Value

void

in Container at line 618
protected string parseBindMethod(array|string $method)

Get the method to be bound in class@method format.

Parameters

array|string $method

Return Value

string

in Container at line 630
mixed callMethodBinding(string $method, mixed $instance)

Get the method binding for the given method.

Parameters

string $method
mixed $instance

Return Value

mixed

in Container at line 642
void addContextualBinding(string $concrete, string $abstract, mixed $implementation)

Add a contextual binding to the container.

Contextual bindings persist on the worker-lifetime container; runtime use races across coroutines and changes dependency resolution for every subsequent build of the concrete.

Parameters

string $concrete
string $abstract
mixed $implementation

Return Value

void

in Container at line 654
void bindIf(Closure|string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding if it hasn't already been registered.

Conditional bindings mutate the worker-lifetime container for every subsequent request.

Parameters

Closure|string $abstract
Closure|string|null $concrete
bool $shared

Return Value

void

in Container at line 680
void singleton(Closure|string $abstract, Closure|string|null $concrete = null)

Register a shared binding in the container.

Singleton bindings persist on the worker-lifetime container; runtime use races across coroutines and changes shared resolution for every subsequent request.

Parameters

Closure|string $abstract
Closure|string|null $concrete

Return Value

void

in Container at line 692
void singletonIf(Closure|string $abstract, Closure|string|null $concrete = null)

Register a shared binding if it hasn't already been registered.

Conditional singleton bindings mutate the worker-lifetime container for every subsequent request.

Parameters

Closure|string $abstract
Closure|string|null $concrete

Return Value

void

in Container at line 704
void scoped(Closure|string $abstract, Closure|string|null $concrete = null)

Register a scoped binding in the container.

Scoped binding definitions persist on the worker-lifetime container; only their resolved instances are coroutine-scoped.

Parameters

Closure|string $abstract
Closure|string|null $concrete

Return Value

void

in Container at line 722
void scopedIf(Closure|string $abstract, Closure|string|null $concrete = null)

Register a scoped binding if it hasn't already been registered.

Conditional scoped bindings mutate the worker-lifetime container for every subsequent request.

Parameters

Closure|string $abstract
Closure|string|null $concrete

Return Value

void

in Container at line 745
protected void bindBasedOnClosureReturnTypes(Closure $abstract, Closure|string|null $concrete = null, bool $shared = false, bool $scoped = false, bool $onlyIfUnbound = false)

Register a binding with the container based on the given Closure's return types.

Parameters

Closure $abstract
Closure|string|null $concrete
bool $shared
bool $scoped
bool $onlyIfUnbound

Return Value

void

in Container at line 773
void extend(string $abstract, Closure $closure)

"Extend" an abstract type in the container.

The extender persists in the container's $extenders array for the worker lifetime and runs on every subsequent resolution of $abstract.

Parameters

string $abstract
Closure $closure

Return Value

void

Exceptions

InvalidArgumentException

in Container at line 819
mixed instance(string $abstract, mixed $instance)

Register an existing instance as shared in the container.

Replaces a worker-lifetime shared instance; runtime use races across coroutines and changes the object returned to every subsequent resolver.

Parameters

string $abstract
mixed $instance

Return Value

mixed

in Container at line 845
protected void removeAbstractAlias(string $searched)

Remove an alias from the contextual binding alias cache.

Parameters

string $searched

Return Value

void

in Container at line 866
void tag(array|string $abstracts, array|string $tags)

Assign a set of tags to a given binding.

Tags persist on the worker-lifetime container and affect every subsequent tagged() resolution.

Parameters

array|string $abstracts
array|string $tags

Return Value

void

in Container at line 885
iterable tagged(string $tag)

Resolve all of the bindings for a given tag.

Parameters

string $tag

Return Value

iterable

in Container at line 906
void alias(string $abstract, string $alias)

Alias a type to a different name.

Aliases persist on the worker-lifetime container; runtime use races across coroutines and changes resolution for every subsequent request.

Parameters

string $abstract
string $alias

Return Value

void

Exceptions

LogicException

in Container at line 936
mixed rebinding(string $abstract, Closure $callback)

Bind a new callback to an abstract's rebind event.

Rebinding callbacks persist on the worker-lifetime container and run whenever the abstract is rebound later in the worker.

Parameters

string $abstract
Closure $callback

Return Value

mixed

in Container at line 954
mixed refresh(string $abstract, mixed $target, string $method)

Refresh an instance on the given target and method.

Registers a rebinding callback on the worker-lifetime container; runtime use leaks the callback across later rebindings.

Parameters

string $abstract
mixed $target
string $method

Return Value

mixed

in Container at line 965
protected void rebound(string $abstract)

Fire the "rebound" callbacks for the given abstract type.

Parameters

string $abstract

Return Value

void

in Container at line 981
protected array getReboundCallbacks(string $abstract)

Get the rebound callbacks for a given type.

Parameters

string $abstract

Return Value

array

in Container at line 989
Closure wrap(Closure $callback, array $parameters = [])

Wrap the given closure such that its dependencies will be injected when executed.

Parameters

Closure $callback
array $parameters

Return Value

Closure

in Container at line 1001
mixed call(callable|string $callback, array $parameters = [], string|null $defaultMethod = null)

Call the given Closure / class@method and inject its dependencies.

Parameters

callable|string $callback
array $parameters
string|null $defaultMethod

Return Value

mixed

Exceptions

InvalidArgumentException

in Container at line 1070
protected string|false getClassForCallable(callable|string $callback)

Get the class name for the given callback, if one can be determined.

Closures are handled directly in call() before this method is reached, so this only needs to handle non-closure callable types.

Parameters

callable|string $callback

Return Value

string|false

in Container at line 1095
Closure factory(string $abstract)

Get a closure to resolve the given type from the container.

Parameters

string $abstract

Return Value

Closure

in Container at line 1110
mixed makeWith(string $abstract, array $parameters = [])

An alias function name for make().

Parameters

string $abstract
array $parameters

Return Value

mixed

Exceptions

BindingResolutionException

in Container at line 1125
mixed make(string $abstract, array $parameters = [])

Resolve the given type from the container.

Parameters

string $abstract
array $parameters

Return Value

mixed

Exceptions

BindingResolutionException

in Container at line 1142
mixed makeTransient(string $abstract)

Resolve the given type with a transient implicit lifetime.

Explicit lifetimes remain authoritative.

Parameters

string $abstract

Return Value

mixed

Exceptions

BindingResolutionException

in Container at line 1156
mixed get(string $id)

No description

Parameters

string $id

Return Value

mixed

Exceptions

CircularDependencyException
EntryNotFoundException

in Container at line 1184
protected mixed resolve(string $abstract, array $parameters = [], bool $raiseEvents = true, bool $transient = false)

Resolve the given type from the container.

Parameters

string $abstract
array $parameters
bool $raiseEvents
bool $transient

Return Value

mixed

Exceptions

BindingResolutionException
CircularDependencyException

in Container at line 1441
protected bool shouldCoordinateSharedResolution(string $abstract, mixed $concrete, bool $needsContextualBuild, bool $raiseEvents)

Determine whether this miss can publish a worker-shared instance.

Parameters

string $abstract
mixed $concrete
bool $needsContextualBuild
bool $raiseEvents

Return Value

bool

in Container at line 1468
protected mixed awaitSharedResolution(string $abstract, SharedResolution $resolution)

Wait for a shared resolution without introducing a coordinator cycle.

Parameters

string $abstract
SharedResolution $resolution

Return Value

mixed

in Container at line 1498
protected bool sharedResolutionOwnerIsAncestor(int $ownerId, int $coroutineId)

Determine whether the resolution owner is an ancestor of a coroutine.

Parameters

int $ownerId
int $coroutineId

Return Value

bool

in Container at line 1518
protected bool sharedResolutionWaitWouldCycle(int $waiterId, int $ownerId)

Determine whether adding a container wait edge would close a cycle.

Parameters

int $waiterId
int $ownerId

Return Value

bool

in Container at line 1534
protected mixed getConcrete(string $abstract)

Get the concrete type for a given abstract.

Parameters

string $abstract

Return Value

mixed

in Container at line 1553
protected mixed getConcreteBindingFromAttributes(string $abstract)

Get the concrete binding for an abstract from the BindWhen or Bind attributes.

Parameters

string $abstract

Return Value

mixed

in Container at line 1589
protected string|null resolveConcreteFromAttributes(ReflectionClass $reflected)

Resolve the concrete from the Bind and BindWhen attributes in declaration order.

Parameters

ReflectionClass $reflected

Return Value

string|null

in Container at line 1627
protected mixed getContextualConcrete(string $abstract)

Get the contextual concrete binding for the given abstract.

Parameters

string $abstract

Return Value

mixed

in Container at line 1656
protected ContainerResolutionState|null getResolutionState()

Get the resolution state for the current coroutine.

Return Value

ContainerResolutionState|null

in Container at line 1666
protected ContainerResolutionState getOrCreateResolutionState()

Get or create the mutable resolution state for the current coroutine.

in Container at line 1681
protected string contextKey(string $name)

Get this container's coroutine context key for the given entry.

Parameters

string $name

Return Value

string

in Container at line 1691
protected array currentBuildStack()

Get the current build stack without creating resolution state.

Return Value

array

in Container at line 1701
protected mixed findInContextualBindings(string $abstract)

Find the concrete binding for the given abstract in the contextual binding array.

Parameters

string $abstract

Return Value

mixed

in Container at line 1715
protected bool isBuildable(mixed $concrete, string $abstract)

Determine if the given concrete is buildable.

Parameters

mixed $concrete
string $abstract

Return Value

bool

in Container at line 1723
protected BuildRecipe getBuildRecipe(string $concrete)

Get the cached build recipe for the given concrete class.

Parameters

string $concrete

Return Value

BuildRecipe

in Container at line 1735
protected BuildRecipe computeBuildRecipe(string $concrete)

Compute the build recipe for the given concrete class.

Analyzes the class via reflection and caches the result as a BuildRecipe. This happens once per class per worker lifetime, avoiding repeated reflection on every build() call.

Parameters

string $concrete

Return Value

BuildRecipe

in Container at line 1815
mixed buildWith(Closure|string $concrete, array $parameters = [])

Instantiate a concrete instance with the given parameter overrides.

Bypasses all binding lookups and the auto-singleton cache, so the returned instance is always freshly constructed. Class-typed dependencies are still resolved via the container.

Parameters

Closure|string $concrete
array $parameters

Return Value

mixed

Exceptions

BindingResolutionException
CircularDependencyException

in Container at line 1841
array resolveContextualParameters(string $concrete, array|null $names = null)

Resolve the contextual constructor parameters of a class within its build context.

Contextual bindings for the class apply to dependencies the attributes resolve, and each parameter's attribute callbacks fire here. Pass the values to buildWith() as overrides so they are not resolved again. Variadic parameters are skipped, because an override is passed as one argument; the container resolves them when the class is built.

Parameters

string $concrete
array|null $names

the parameters to resolve, or null for every contextual parameter

Return Value

array

Exceptions

BindingResolutionException

in Container at line 1887
mixed build(Closure|string $concrete)

Instantiate a concrete instance of the given type.

Parameters

Closure|string $concrete

Return Value

mixed

Exceptions

BindingResolutionException
CircularDependencyException

in Container at line 1962
protected mixed buildForResolution(Closure|string $concrete, ContainerResolutionState $resolutionState)

Build a concrete as part of container resolution.

Parameters

Closure|string $concrete
ContainerResolutionState $resolutionState

Return Value

mixed

in Container at line 1989
protected mixed buildSelfBuildingInstance(string $concrete, BuildRecipe $recipe, ContainerResolutionState $resolutionState)

Instantiate a concrete instance of the given self building type.

Parameters

string $concrete
BuildRecipe $recipe
ContainerResolutionState $resolutionState

Return Value

mixed

Exceptions

BindingResolutionException

in Container at line 2021
protected array resolveRecipeParameters(BuildRecipe $recipe, ContainerResolutionState $resolutionState)

Resolve all constructor parameters using cached recipe metadata.

Parameters

BuildRecipe $recipe
ContainerResolutionState $resolutionState

Return Value

array

Exceptions

BindingResolutionException

in Container at line 2076
protected mixed resolvePrimitive(ParameterRecipe $param)

Resolve a non-class hinted primitive dependency.

Parameters

ParameterRecipe $param

Return Value

mixed

Exceptions

BindingResolutionException

in Container at line 2102
protected mixed resolveClass(ParameterRecipe $param)

Resolve a class based dependency from the container.

Parameters

ParameterRecipe $param

Return Value

mixed

Exceptions

BindingResolutionException

in Container at line 2132
protected mixed resolveVariadicClass(ParameterRecipe $param)

Resolve a class based variadic dependency from the container.

Parameters

ParameterRecipe $param

Return Value

mixed

in Container at line 2150
mixed resolveFromAttribute(ReflectionAttribute $attribute, ReflectionParameter $parameter)

Resolve a dependency based on an attribute.

Parameters

ReflectionAttribute $attribute
ReflectionParameter $parameter

Return Value

mixed

Exceptions

BindingResolutionException

in Container at line 2172
protected never notInstantiable(string $concrete)

Throw an exception that the concrete is not instantiable.

Parameters

string $concrete

Return Value

never

Exceptions

BindingResolutionException

in Container at line 2192
protected never unresolvablePrimitive(ParameterRecipe $param)

Throw an exception for an unresolvable primitive.

Parameters

ParameterRecipe $param

Return Value

never

Exceptions

BindingResolutionException

in Container at line 2205
void beforeResolving(Closure|string $abstract, Closure|null $callback = null)

Register a new before resolving callback for all types.

The callback persists on the worker-lifetime container and runs before every matching future resolution.

Parameters

Closure|string $abstract
Closure|null $callback

Return Value

void

in Container at line 2225
void resolving(Closure|string $abstract, Closure|null $callback = null)

Register a new resolving callback.

The callback persists on the worker-lifetime container and runs during every matching future resolution.

Parameters

Closure|string $abstract
Closure|null $callback

Return Value

void

in Container at line 2245
void afterResolving(Closure|string $abstract, Closure|null $callback = null)

Register a new after resolving callback for all types.

The callback persists on the worker-lifetime container and runs after every matching future resolution.

Parameters

Closure|string $abstract
Closure|null $callback

Return Value

void

in Container at line 2265
void afterResolvingAttribute(string $attribute, Closure $callback)

Register a new after resolving attribute callback for all types.

The callback persists on the worker-lifetime container and runs after every future resolution with the matching attribute.

Parameters

string $attribute
Closure $callback

Return Value

void

in Container at line 2274
protected void fireBeforeResolvingCallbacks(string $abstract, array $parameters = [])

Fire all of the before resolving callbacks.

Parameters

string $abstract
array $parameters

Return Value

void

in Container at line 2292
protected void fireBeforeCallbackArray(string $abstract, array $parameters, array $callbacks)

Fire an array of callbacks with an object.

Parameters

string $abstract
array $parameters
array $callbacks

Return Value

void

in Container at line 2302
protected void fireResolvingCallbacks(string $abstract, mixed $object)

Fire all of the resolving callbacks.

Parameters

string $abstract
mixed $object

Return Value

void

in Container at line 2321
protected void fireAfterResolvingCallbacks(string $abstract, mixed $object)

Fire all of the after resolving callbacks.

Parameters

string $abstract
mixed $object

Return Value

void

in Container at line 2333
void fireAfterResolvingAttributeCallbacks(array $attributes, mixed $object)

Fire all of the after resolving attribute callbacks.

Parameters

array $attributes
mixed $object

Return Value

void

in Container at line 2365
protected void fireCallbacksForType(string $abstract, mixed $object, array $callbacksPerType)

Fire all callbacks that match the given abstract or object type.

Parameters

string $abstract
mixed $object
array $callbacksPerType

Return Value

void

in Container at line 2379
protected void fireCallbackArray(mixed $object, array $callbacks)

Fire an array of callbacks with an object.

Parameters

mixed $object
array $callbacks

Return Value

void

in Container at line 2389
int|string|null currentlyResolving()

Get the class name or closure object ID the container is currently resolving.

Return Value

int|string|null

in Container at line 2397
array getBindings()

Get the container's bindings.

Return Value

array

in Container at line 2405
string getAlias(string $abstract)

Get the alias for an abstract if available.

Parameters

string $abstract

Return Value

string

in Container at line 2416
protected array getExtenders(string $abstract)

Get the extender callbacks for a given type.

Parameters

string $abstract

Return Value

array

in Container at line 2427
void forgetExtenders(string $abstract)

Remove all of the extender callbacks for a given type.

Clears worker-lifetime extender callbacks; concurrent resolutions may diverge depending on whether they resolved before or after the removal.

Parameters

string $abstract

Return Value

void

in Container at line 2436
protected void dropStaleInstances(string $abstract)

Drop all of the stale instances and aliases.

Parameters

string $abstract

Return Value

void

in Container at line 2447
protected void forgetCachedInstances(string $abstract)

Forget every cached instance for an abstract without changing its lifecycle.

Parameters

string $abstract

Return Value

void

in Container at line 2461
void forgetInstance(string $abstract)

Remove a resolved instance from the instance cache.

Clears a worker-lifetime shared instance and current coroutine scoped instance; concurrent coroutines may still hold references that next resolution will not share.

Parameters

string $abstract

Return Value

void

in Container at line 2474
void forgetInstances()

Clear all of the instances from the container.

Clears worker-lifetime shared instances and all scoped context entries known to this container; concurrent coroutines may still hold references that next resolution will not share.

Return Value

void

in Container at line 2488
void forgetScopedInstances()

Clear all of the scoped instances from the container.

Clears this container's scoped instances in the current coroutine; runtime use can invalidate scoped services while the request is still using them.

Return Value

void

in Container at line 2504
void resolveEnvironmentUsing(callable|null $callback)

Set the callback which determines the current container environment.

The resolver persists on the worker-lifetime container and is used by every currentEnvironmentIs() call.

Parameters

callable|null $callback

Return Value

void

in Container at line 2515
bool currentEnvironmentIs(array|string $environments)

Determine the environment for the container.

Parameters

array|string $environments

Return Value

bool

at line 1599
void flush()

Flush the container of all bindings and resolved instances.

Clears the worker-lifetime application registry; runtime use breaks every concurrent resolution in the worker.

Return Value

void

in Container at line 2558
void __clone()

Give the cloned container its own coroutine context entries.

Like its shared instances, the clone starts with the scoped instances resolved in the current coroutine, but forgetting or replacing them on one container leaves the other's untouched.

Return Value

void

in Container at line 2577
static Container getInstance()

Get the globally available instance of the container.

Return Value

Container

in Container at line 2588
static Container|null setInstance(Container|null $container = null)

Set the shared instance of the container.

Replaces the process-wide container singleton; runtime use races across coroutines and breaks every facade/global container lookup.

Parameters

Container|null $container

Return Value

Container|null

at line 1623
static void flushState()

Flush all static state.

Return Value

void

in Macroable at line 30
static void macro(string $name, callable|object $macro)

Register a custom macro.

Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 44
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 72
static void flushMacros()

Flush the existing macros.

Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 83
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 108
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 188
__construct(string|null $basePath = null)

No description

Parameters

string|null $basePath

at line 204
protected void checkEnvironment()

Check that the runtime environment is properly configured.

Return Value

void

at line 232
static ApplicationBuilder configure(string|null $basePath = null)

Configure and create a new application builder instance.

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

Parameters

string|null $basePath

Return Value

ApplicationBuilder

at line 254
static string inferBasePath()

Infer the application's base directory from the environment.

Precedence is $_ENV, $_SERVER, Env repository, then Composer. Hypervel checks $_SERVER and Env so test helpers and worker environments can provide APP_BASE_PATH without writing to $_ENV.

Return Value

string

at line 271
string version()

Get the version number of the application.

Return Value

string

at line 279
protected void registerBaseBindings()

Register the basic bindings into the container.

Return Value

void

at line 313
protected void registerBaseServiceProviders()

Register all of the base service providers.

Return Value

void

at line 338
void bootstrapWith(array $bootstrappers)

Run the given array of bootstrap classes.

Parameters

array $bootstrappers

Return Value

void

at line 354
void beforeBootstrapping(string $bootstrapper, Closure $callback)

Register a callback to run before a bootstrapper.

Parameters

string $bootstrapper
Closure $callback

Return Value

void

at line 362
void afterBootstrapping(string $bootstrapper, Closure $callback)

Register a callback to run after a bootstrapper.

Parameters

string $bootstrapper
Closure $callback

Return Value

void

at line 370
void afterLoadingEnvironment(Closure $callback)

Register a callback to run after loading the environment.

Parameters

Closure $callback

Return Value

void

at line 381
bool hasBeenBootstrapped()

Determine if the application has been bootstrapped before.

Return Value

bool

at line 394
Application setBasePath(string $basePath)

Set the base path for the application.

Rebinds path instances on the singleton container; runtime use races across coroutines and breaks every concurrent path resolution.

Parameters

string $basePath

Return Value

Application

at line 410
protected void bindPathsInContainer()

Bind all of the application paths in the container.

Rebinds path instances on the singleton container; runtime use races across coroutines and breaks every concurrent path resolution.

Return Value

void

at line 433
string path(string $path = '')

Get the path to the application "app" directory.

Parameters

string $path

Return Value

string

at line 446
Application useAppPath(string $path)

Set the application directory.

The configured path and its container binding are shared by every request in the worker.

Parameters

string $path

Return Value

Application

at line 459
string basePath(string $path = '')

Get the base path of the Hypervel installation.

Parameters

string $path

Return Value

string

at line 467
string bootstrapPath(string $path = '')

Get the path to the bootstrap directory.

Parameters

string $path

Return Value

string

at line 480
Application useBootstrapPath(string $path)

Set the bootstrap file directory.

The configured path and its container binding are shared by every request in the worker.

Parameters

string $path

Return Value

Application

at line 493
string getBootstrapProvidersPath()

Get the path to the service provider list in the bootstrap directory.

Return Value

string

at line 501
string configPath(string $path = '')

Get the path to the application configuration files.

Parameters

string $path

Return Value

string

at line 514
Application useConfigPath(string $path)

Set the configuration directory.

The configured path and its container binding are shared by every request in the worker.

Parameters

string $path

Return Value

Application

at line 527
string databasePath(string $path = '')

Get the path to the database directory.

Parameters

string $path

Return Value

string

at line 540
Application useDatabasePath(string $path)

Set the database directory.

The configured path and its container binding are shared by every request in the worker.

Parameters

string $path

Return Value

Application

at line 553
string langPath(string $path = '')

Get the path to the language files.

Parameters

string $path

Return Value

string

at line 566
Application useLangPath(string $path)

Set the language file directory.

The configured path and its container binding are shared by every request in the worker.

Parameters

string $path

Return Value

Application

at line 579
string publicPath(string $path = '')

Get the path to the public directory.

Parameters

string $path

Return Value

string

at line 592
Application usePublicPath(string $path)

Set the public / web directory.

The configured path and its container binding are shared by every request in the worker.

Parameters

string $path

Return Value

Application

at line 605
string resourcePath(string $path = '')

Get the path to the resources directory.

Parameters

string $path

Return Value

string

at line 615
string viewPath(string $path = '')

Get the path to the views directory.

This method returns the first configured path in the array of view paths.

Parameters

string $path

Return Value

string

at line 630
string storagePath(string $path = '')

Get the path to the storage directory.

Parameters

string $path

Return Value

string

at line 651
Application useStoragePath(string $path)

Set the storage directory.

The configured path and its container binding are shared by every request in the worker.

Parameters

string $path

Return Value

Application

at line 664
string|null environmentPath()

Get the path to the environment file directory.

Return Value

string|null

at line 676
Application useEnvironmentPath(string $path)

Set the directory for the environment file.

The configured path is shared by every request in the worker.

Parameters

string $path

Return Value

Application

at line 691
Application loadEnvironmentFrom(string $file)

Set the environment file to be loaded during bootstrapping.

The configured filename is shared by every request in the worker.

Parameters

string $file

Return Value

Application

at line 702
string environmentFile()

Get the environment file the application is using.

Return Value

string

at line 710
string environmentFilePath()

Get the fully-qualified path to the environment file.

Return Value

string

at line 718
bool configurationIsCached()

Determine if the application configuration is cached.

Return Value

bool

at line 732
string getCachedConfigPath()

Get the path to the configuration cache file.

Return Value

string

at line 740
string getCachedPackagesPath()

Get the path to the cached packages.php file.

Return Value

string

at line 748
bool routesAreCached()

Determine if the application routes are cached.

Return Value

bool

at line 760
string getCachedRoutesPath()

Get the path to the routes cache file.

Return Value

string

at line 768
bool eventsAreCached()

Determine if the application events are cached.

Return Value

bool

at line 780
string getCachedEventsPath()

Get the path to the events cache file.

Return Value

string

at line 788
protected string normalizeCachePath(string $key, string $default)

Normalize a relative or absolute path to a cache file.

Parameters

string $key
string $default

Return Value

string

at line 808
Application addAbsoluteCachePathPrefix(string $prefix)

Add new prefix to list of absolute path prefixes.

The prefix persists on the application singleton and affects cache-path resolution for every request in the worker.

Parameters

string $prefix

Return Value

Application

at line 819
string joinPaths(string|null $basePath, string $path = '')

Join the given paths together.

Parameters

string|null $basePath
string $path

Return Value

string

at line 827
bool|string environment(UnitEnum|array|string ...$environments)

Get or check the current application environment.

Parameters

UnitEnum|array|string ...$environments

Return Value

bool|string

at line 843
bool isLocal()

Determine if the application is in the local environment.

Return Value

bool

at line 851
bool isProduction()

Determine if the application is in the production environment.

Return Value

bool

at line 861
string detectEnvironment(Closure $callback)

Detect the application's current environment.

The detected environment is shared by every request in the worker.

Parameters

Closure $callback

Return Value

string

at line 877
bool runningInConsole()

Determine if the application is running in the console.

In Swoole, PHP_SAPI is always 'cli', so this defaults to true. The server command sets it to false before starting the HTTP server, and workers inherit that value.

Return Value

bool

at line 890
bool runningConsoleCommand(string|array ...$commands)

Determine if the application is running any of the given console commands.

Parameters

string|array ...$commands

Return Value

bool

at line 909
void setRunningInConsole(bool $runningInConsole)

Set whether the application is running in the console.

The flag persists on the singleton Application for the worker lifetime and is read by every runningInConsole() check across all coroutines.

Parameters

bool $runningInConsole

Return Value

void

at line 918
bool runningUnitTests()

Determine if the application is running unit tests.

Return Value

bool

at line 926
bool hasDebugModeEnabled()

Determine if the application is running with debug mode enabled.

Return Value

bool

at line 934
MaintenanceMode maintenanceMode()

Get an instance of the maintenance mode manager implementation.

Return Value

MaintenanceMode

at line 942
bool isDownForMaintenance()

Determine if the application is currently down for maintenance.

Return Value

bool

at line 952
int handleCommand(InputInterface $input)

Handle the incoming Artisan command.

Parameters

InputInterface $input

Return Value

int

at line 969
bool shouldMergeFrameworkConfiguration()

Determine if the framework's base configuration should be merged.

Return Value

bool

at line 982
Application dontMergeFrameworkConfiguration()

Indicate that the framework's base configuration should not be merged.

The setting changes configuration bootstrap behavior for the entire worker.

Return Value

Application

at line 993
bool shouldSkipMiddleware()

Determine if middleware has been disabled for the application.

Return Value

bool

at line 1005
void registered(callable $callback)

Register a new registered listener.

The callback persists in the Application's registeredCallbacks array and fires once per service provider registration during boot.

Parameters

callable $callback

Return Value

void

at line 1022
void registerConfiguredProviders()

Register all of the configured providers.

Providers are loaded in three tiers:

  1. Framework providers (Hypervel* from app.providers) — always first
  2. Discovered providers (from composer packages) — sorted by priority
  3. Application providers (non-Hypervel* from app.providers) — always last

The providers' bindings persist on the application for every subsequent request in the worker.

Return Value

void

at line 1044
protected array discoverProviders()

Discover service providers from installed composer packages.

Return Value

array

at line 1058
static protected array sortByPriority(array $providers)

Sort providers by their priority property in descending order.

Higher priority values are loaded first. Providers with the same priority preserve their original order (stable sort).

Parameters

array $providers

Return Value

array

at line 1087
ServiceProvider register(ServiceProvider|string $provider, bool $force = false)

Register a service provider with the application.

The provider's bindings persist on the application for every subsequent request in the worker.

Parameters

ServiceProvider|string $provider
bool $force

Return Value

ServiceProvider

at line 1142
ServiceProvider|null getProvider(ServiceProvider|string $provider)

Get the registered service provider instance if it exists.

Parameters

ServiceProvider|string $provider

Return Value

ServiceProvider|null

at line 1152
array getProviders(ServiceProvider|string $provider)

Get the registered service provider instances if any exist.

Parameters

ServiceProvider|string $provider

Return Value

array

at line 1162
ServiceProvider resolveProvider(string $provider)

Resolve a service provider instance from the class name.

Parameters

string $provider

Return Value

ServiceProvider

at line 1170
protected void markAsRegistered(ServiceProvider $provider)

Mark the given provider as registered.

Parameters

ServiceProvider $provider

Return Value

void

at line 1184
bool isBooted()

Determine if the application has booted.

Return Value

bool

at line 1192
void boot()

Boot the application's service providers.

Return Value

void

at line 1222
protected void bootProvider(ServiceProvider $provider)

Boot the given service provider.

Parameters

ServiceProvider $provider

Return Value

void

at line 1240
void booting(callable $callback)

Register a new boot listener.

The callback fires once during application boot; runtime use after boot stores the closure on the singleton Application with no future boot to listen for.

Parameters

callable $callback

Return Value

void

at line 1253
void booted(callable $callback)

Register a new "booted" listener.

If the app has already booted, the callback fires immediately and is never invoked again, but remains stored on the singleton Application for the worker lifetime.

Parameters

callable $callback

Return Value

void

at line 1273
Application terminating(callable|string $callback)

Register a terminating callback with the application.

Callbacks persist for the worker's lifetime and fire on every subsequent request — per-request use leaks the closure and anything it captures across every request the worker handles. Use defer() for per-request "after the response" cleanup.

Parameters

callable|string $callback

Return Value

Application

at line 1284
void terminate()

Terminate the application.

Return Value

void

at line 1310
protected void fireAppCallbacks(array $callbacks)

Call the booting callbacks for the application.

Parameters

array $callbacks

Return Value

void

at line 1327
never abort(int $code, string $message = '', array $headers = [])

Throw an HttpException with the given data.

Parameters

int $code
string $message
array $headers

Return Value

never

Exceptions

HttpException
NotFoundHttpException

at line 1341
array getLoadedProviders()

Get the service providers that have been loaded.

Return Value

array

at line 1349
bool providerIsLoaded(string $provider)

Determine if the given service provider is loaded.

Parameters

string $provider

Return Value

bool

at line 1357
string getLocale()

Get the current application locale.

Return Value

string

at line 1365
bool isLocale(string $locale)

Determine if the application locale is the given locale.

Parameters

string $locale

Return Value

bool

at line 1373
string currentLocale()

Get the current application locale.

Return Value

string

at line 1381
string getFallbackLocale()

Get the current application fallback locale.

Return Value

string

at line 1389
void setLocale(string $locale)

Set the current application locale.

Parameters

string $locale

Return Value

void

at line 1411
void setFallbackLocale(string $fallbackLocale)

Set the current application fallback locale.

The fallback is stored on the shared translator and affects every request in the worker.

Parameters

string $fallbackLocale

Return Value

void

at line 1432
protected void registerCoreContainerAliases()

Register the core class aliases in the container.

Keys are canonical string binding names (matching Laravel). Values are class/interface aliases that resolve to the same binding. When code calls make(SomeClass::class), getAlias() maps it to the string key, which finds the service provider's binding.

IMPORTANT: When a service has a string binding (via singleton/bind in a service provider), its concrete and contract classes MUST be listed here as aliases. Hypervel's container auto-singletons unbound concrete classes — if a class isn't aliased to its string key, make(Class::class) bypasses the string binding and creates a separate cached instance, resulting in two instances of the same service in the container.

Return Value

void

at line 1635
string getNamespace()

Get the application namespace.

Return Value

string

Exceptions

RuntimeException