Methods |
public
|
__construct(
string|null $basePath = null,
non-empty-string|null $name = null,
int-mask-of<Env::APPLY_*> $envFlags = Env::APPLY_ALL,
string|null $configDir = 'config',
)
Creates a new service container
Creates a new service container
This container:
- makes itself the global container
- gets the current environment from {@see Env::getEnvironment()}, checks
for the following files, and loads values into the environment from the
first that exists:
<base_path>/.env.<environment>
<base_path>/.env
- applies values from the environment to the running script (if
$envFlags is non-zero)
- calls {@see Console::registerStderrTarget()} to register
STDERR for
console output if running on the command line
- calls {@see Err::register()} to register error, exception and shutdown
handlers
- calls {@see Config::loadDirectory()} to load values from files in
$configDir (if it exists and is a directory)
Parameters
$basePath |
If null , the value of environment variable
app_base_path is used if present, otherwise the path of the root
package is used.
|
$name |
If null , configuration value
"app.name" is used if set, otherwise the basename of the file used to
run the script is used after removing common PHP file extensions and
recognised version numbers.
|
$envFlags |
Values to apply from the
environment to the running script.
|
$configDir |
An absolute path, a path relative to the
application's base path, or null if configuration files should not be
loaded.
|
Implements
|
#
|
public
|
unload(): void
Close the object's underlying resources
Close the object's underlying resources
Overrides
Implements
|
#
|
public
|
getName(): string
Get the name of the application
Get the name of the application
Implements
|
#
|
public
|
getVersion(bool $withRef = true): string
Get the version of the application, optionally including its commit
reference
Get the version of the application, optionally including its commit
reference
Implements
|
#
|
public
|
getVersionString(): string
Get the application's name, version and commit reference, followed by the
PHP version
Get the application's name, version and commit reference, followed by the
PHP version
Implements
|
#
|
public
|
getBasePath(): string
Get the application's base path
Get the application's base path
Implements
|
#
|
public
|
getCachePath(bool $create = true): string
Get a cache directory for the application
Get a cache directory for the application
Implements
|
#
|
public
|
getConfigPath(bool $create = true): string
Get a directory for configuration files created by the application
Get a directory for configuration files created by the application
Implements
|
#
|
public
|
getDataPath(bool $create = true): string
Get a data directory for the application
Get a data directory for the application
Implements
|
#
|
public
|
getLogPath(bool $create = true): string
Get a directory for the application's log files
Get a directory for the application's log files
Implements
|
#
|
public
|
getTempPath(bool $create = true): string
Get a directory for the application's temporary files
Get a directory for the application's temporary files
Implements
|
#
|
public
|
isRunningInProduction(): bool
Check if the application is running in a production environment
Check if the application is running in a production environment
Implements
|
#
|
public
|
hasOutputLog(): bool
Check if console output is being logged to the application's log
directory
Check if console output is being logged to the application's log
directory
Implements
|
#
|
public
|
logOutput(?string $name = null, ?bool $debug = null)
Log console output to the application's log directory
Log console output to the application's log directory
Messages with levels between LEVEL_EMERGENCY and LEVEL_INFO are
written to <name>.log .
If $debug is true , or $debug is null and debug mode is enabled in
the environment, messages with levels between LEVEL_EMERGENCY and
LEVEL_DEBUG are also written to <name>.debug.log .
Parameters
$name |
If null , the name of the application is used.
|
Implements
|
#
|
public
|
hasHarRecorder(): bool
Check if the application's HTTP requests are being recorded
Check if the application's HTTP requests are being recorded
Returns true if {@see recordHar()} has been called, even if no
subsequent HTTP requests have been made.
Implements
|
#
|
public
|
recordHar(?string $name = null, ?string $creatorName = null, ?string $creatorVersion = null, $uuid = null)
Record the application's HTTP requests to an HTTP Archive (HAR) file in
its log directory
Record the application's HTTP requests to an HTTP Archive (HAR) file in
its log directory
If any HTTP requests are made via {@see CurlerInterface} implementations,
they are recorded in <name>-<timestamp>-<uuid>.har .
Parameters
$name |
If null , the name of the application is used.
|
Implements
|
#
|
public
|
getHarFilename(): ?string
Get the name of the application's HTTP Archive (HAR) file if it exists
Get the name of the application's HTTP Archive (HAR) file if it exists
Returns null if {@see recordHar()} has been called but no HTTP requests
have been made.
Implements
|
#
|
public
|
hasCache(): bool
Check if a cache has been started for the application
Check if a cache has been started for the application
Implements
|
#
|
public
|
startCache()
Start a cache for the application and make it the global cache
Start a cache for the application and make it the global cache
If the cache is filesystem-backed, it is started in the application's
cache directory.
Implements
|
#
|
public
|
stopCache()
Stop the application's cache if started
Stop the application's cache if started
Implements
|
#
|
public
|
hasSync(): bool
Check if a sync entity store has been started for the application
Check if a sync entity store has been started for the application
Implements
|
#
|
public
|
startSync(?string $command = null, string[]|null $arguments = null)
Start a sync entity store for the application and make it the global sync
entity store
Start a sync entity store for the application and make it the global sync
entity store
If the entity store is filesystem-backed, it is started in the
application's data directory.
Implements
|
#
|
public
|
stopSync()
Stop the application's sync entity store if started
Stop the application's sync entity store if started
Implements
|
#
|
public
|
sync(string $prefix, string $uri, string $namespace, ?SyncNamespaceHelperInterface $helper = null)
Register a namespace for sync entities and their provider interfaces with
the application's sync entity store, starting…
Register a namespace for sync entities and their provider interfaces with
the application's sync entity store, starting it if necessary
Implements
|
#
|
public
|
getInitialWorkingDirectory(): string
Get the directory in which the application was started
Get the directory in which the application was started
Implements
|
#
|
public
|
setInitialWorkingDirectory(string $directory)
Set the directory in which the application was started
Set the directory in which the application was started
Implements
|
#
|
public
|
restoreWorkingDirectory()
Change to the directory in which the application was started
Change to the directory in which the application was started
Implements
|
#
|
public
|
reportVersion(int $level = Console::LEVEL_INFO)
Write the application's name, version and commit reference, followed by
the PHP version, to the console
Write the application's name, version and commit reference, followed by
the PHP version, to the console
Implements
|
#
|
public
|
reportResourceUsage(int $level = Console::LEVEL_INFO)
Write a summary of the application's system resource usage to the console
Write a summary of the application's system resource usage to the console
Implements
|
#
|
public
|
reportMetrics(int $level = Console::LEVEL_INFO, bool $includeRunningTimers = true, $groups = null, ?int $limit = 10)
Write a summary of the application's runtime performance metrics to the
console
Write a summary of the application's runtime performance metrics to the
console
Parameters
$groups |
If null or ["*"] , all metrics are
reported, otherwise only metrics in the given groups are reported.
|
Implements
|
#
|
public
|
registerShutdownReport(
int $level = Console::LEVEL_INFO,
bool $includeResourceUsage = true,
bool $includeRunningTimers = true,
$groups = null,
?int $limit = 10,
)
Write a summary of the application's runtime performance metrics and
system resource usage to the console when it…
Write a summary of the application's runtime performance metrics and
system resource usage to the console when it terminates
Parameters
$groups |
If null or ["*"] , all metrics are
reported, otherwise only metrics in the given groups are reported.
|
Implements
|
#
|