Methods |
public
|
__construct(
?string $basePath = null,
?string $appName = null,
int-mask-of<Env::APPLY_*> $envFlags = Env::APPLY_ALL,
string|null $configDir = 'config',
)
Creates a new Application object
Creates a new Application object
If $basePath is null , the value of environment variable
app_base_path is used if present, otherwise the path of the root
package is used.
If $appName is null , the basename of the file used to run the script
is used after removing common PHP file extensions and recognised version
numbers.
If $configDir exists and is a directory, it is passed to
{@see Config::loadDirectory()} after .env files are loaded and values
are applied from the environment to the running script.
Parameters
$envFlags |
Values to apply from the
environment to the running script.
|
$configDir |
A path relative to the application's base
path, or null if configuration files should not be loaded.
|
Overrides
Overriden by
Implements
|
#
|
public
|
unload(): void
Close the object's underlying resources
Close the object's underlying resources
Overrides
Implements
|
#
|
final
public
|
getAppName(): string
Get the name of the application
Get the name of the application
Implements
|
#
|
public
|
isProduction(): bool
Check if the application is running in a production environment
Check if the application is running in a production environment
Returns true if:
- the name of the current environment is
"production"
- the application is running from a Phar archive, or
- the application was installed with
composer --no-dev
Implements
|
#
|
final
public
|
getBasePath(): string
Get the application's base path
Get the application's base path
Implements
|
#
|
final
public
|
getCachePath(bool $create = true): string
Get a writable cache directory for the application
Get a writable cache directory for the application
Appropriate for replaceable data that should persist between runs to
improve performance.
Implements
|
#
|
final
public
|
getConfigPath(bool $create = true): string
Get a writable directory for configuration files created by the
application
Get a writable directory for configuration files created by the
application
Implements
|
#
|
final
public
|
getDataPath(bool $create = true): string
Get a writable data directory for the application
Get a writable data directory for the application
Appropriate for critical data that should persist indefinitely.
Implements
|
#
|
final
public
|
getLogPath(bool $create = true): string
Get a writable directory for the application's log files
Get a writable directory for the application's log files
Implements
|
#
|
final
public
|
getTempPath(bool $create = true): string
Get a writable directory for the application's ephemeral data
Get a writable directory for the application's ephemeral data
Implements
|
#
|
final
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 {@see Level::EMERGENCY} and
{@see 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 {@see Level::EMERGENCY} and
{@see Level::DEBUG} are simultaneously written to <name>.debug.log .
Parameters
$name |
If null , the name of the application is used.
|
Implements
|
#
|
final
public
|
exportHar(?string $name = null, ?string $creatorName = null, ?string $creatorVersion = null, $uuid = null)
Export the application's HTTP requests to an HTTP Archive (HAR) file in
its log directory
Export the application's HTTP requests to an HTTP Archive (HAR) file in
its log directory
If any requests are made via {@see CurlerInterface} objects,
<name>-<timestamp>-<uuid>.har is created to record them.
Parameters
$name |
If null , the name of the application is used.
|
Implements
|
#
|
final
public
|
getHarFilename(): ?string
Get the name of the HTTP Archive (HAR) file created via exportHar() if it
has been created
Get the name of the HTTP Archive (HAR) file created via exportHar() if it
has been created
Implements
|
#
|
final
public
|
startCache()
Start a cache store and make it the global cache
Start a cache store and make it the global cache
If the cache store is filesystem-backed, the application's cache
directory is used.
Implements
|
#
|
final
public
|
resumeCache()
Start a cache store and make it the global cache if a previously started
cache store exists, otherwise do nothing
Start a cache store and make it the global cache if a previously started
cache store exists, otherwise do nothing
Implements
|
#
|
final
public
|
stopCache()
Stop a cache store started by startCache() or resumeCache()
Stop a cache store started by startCache() or resumeCache()
Implements
|
#
|
final
public
|
startSync(?string $command = null, ?array $arguments = null)
Start an entity store and make it the global sync entity store
Start an entity store and make it the global sync entity store
If the entity store is filesystem-backed, the application's data
directory is used.
Implements
|
#
|
final
public
|
stopSync()
Stop an entity store started by startSync()
Stop an entity store started by startSync()
Implements
|
#
|
final
public
|
registerSyncNamespace(string $prefix, string $uri, string $namespace, ?SyncNamespaceHelperInterface $helper = null)
Register a namespace for sync entities and their provider interfaces with
the global sync entity store
Register a namespace for sync entities and their provider interfaces with
the global sync entity store
Implements
|
#
|
final
public
|
getWorkingDirectory(): string
Get the application's working directory
Get the application's working directory
The application's working directory is either the directory it was
started in, or the directory most recently set via
{@see ApplicationInterface::setWorkingDirectory()}.
Implements
|
#
|
final
public
|
restoreWorkingDirectory()
Change to the application's working directory
Change to the application's working directory
Implements
|
#
|
final
public
|
setWorkingDirectory(?string $directory = null)
Set the application's working directory
Set the application's working directory
Parameters
$directory |
If null , the current working directory is
used.
|
Implements
|
#
|
final
public
|
registerShutdownReport(
int $level = MessageLevel::INFO,
bool $includeResourceUsage = true,
bool $includeRunningTimers = true,
$groups = null,
?int $limit = 10,
)
Print a summary of the application's runtime performance metrics and
system resource usage when it terminates
Print a summary of the application's runtime performance metrics and
system resource usage when it terminates
Parameters
$groups |
If null or ["*"] , all metrics are
reported, otherwise only metrics in the given groups are reported.
|
Implements
|
#
|
final
public
|
reportResourceUsage(int $level = MessageLevel::INFO)
Print a summary of the application's system resource usage
Print a summary of the application's system resource usage
Implements
|
#
|
final
public
|
reportMetrics(int $level = MessageLevel::INFO, bool $includeRunningTimers = true, $groups = null, ?int $limit = 10)
Print a summary of the application's runtime performance metrics
Print a summary of the application's runtime performance metrics
Parameters
$groups |
If null or ["*"] , all metrics are
reported, otherwise only metrics in the given groups are reported.
|
Implements
|
#
|