Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Gets the value of a single or all environment variables
<?php getenv(?string $name = null, bool $local_only = false): string|array|false
<?php (new LoadEnvironmentVariables)->bootstrap($this->getAppMock('.env'));
$this->assertSame('BAR', env('FOO'));
$this->assertSame('BAR', getenv('FOO'));
$this->assertSame('BAR', $_ENV['FOO']);
$this->assertSame('BAR', $_SERVER['FOO']);
}
<?php {
protected function getEnvironmentSetUp($app)
{
if (getenv('DB_CONNECTION') !== 'testing') {
$this->markTestSkipped('Test requires a Sqlite connection.');
}
<?php {
protected function getEnvironmentSetUp($app)
{
if (getenv('DB_CONNECTION') !== 'testing') {
$this->markTestSkipped('Test requires a Sqlite connection.');
}
<?php {
protected function getEnvironmentSetUp($app)
{
if (getenv('DB_CONNECTION') !== 'testing') {
$this->markTestSkipped('Test requires a Sqlite connection.');
}
<?php {
protected function getEnvironmentSetUp($app)
{
if (getenv('DB_CONNECTION') !== 'testing') {
$this->markTestSkipped('Test requires a Sqlite connection.');
}
<?php $wantsToSupport = false;
if (getenv('PEST_NO_SUPPORT') !== 'true' && $this->input->isInteractive()) {
$wantsToSupport = (new SymfonyQuestionHelper())->ask(
new ArrayInput([]),
$this->output,
<?php return;
}
$flowId = getenv('FLOW_ID');
$flowId = is_string($flowId) ? (int) $flowId : getmypid();
new TeamCityLogger(
<?php $this->output,
new Converter($this->testSuite->rootPath),
$flowId === false ? null : $flowId,
getenv('COLLISION_IGNORE_DURATION') !== false
);
}
}
<?php ], $process->getOutput());
};
if (getenv('REBUILD_SNAPSHOTS')) {
$outputContent = explode("\n", $output());
array_pop($outputContent);
array_pop($outputContent);
<?php array_pop($outputContent);
file_put_contents($snapshot, implode("\n", $outputContent));
} elseif (! getenv('EXCLUDE')) {
$output = explode("\n", $output());
array_pop($output);
array_pop($output);
<?php expect(implode("\n", $output))->toContain(file_get_contents($snapshot));
}
})->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'))
->skipOnWindows();
<?php return $process->getOutput();
};
if (getenv('REBUILD_SNAPSHOTS')) {
file_put_contents($snapshot, normalize_windows_os_output($output()));
} elseif (! getenv('EXCLUDE')) {
expect(normalize_windows_os_output($output()))->toEqual(file_get_contents($snapshot));
<?php if (getenv('REBUILD_SNAPSHOTS')) {
file_put_contents($snapshot, normalize_windows_os_output($output()));
} elseif (! getenv('EXCLUDE')) {
expect(normalize_windows_os_output($output()))->toEqual(file_get_contents($snapshot));
}
})->with([
<?php })->with([
'Failure.php',
'SuccessOnly.php',
])->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'));
<?php };
expect($output())->toMatchSnapshot();
})->skipOnWindows()->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'));