本文整理汇总了PHP中Dotenv\Dotenv类的典型用法代码示例。如果您正苦于以下问题:PHP Dotenv类的具体用法?PHP Dotenv怎么用?PHP Dotenv使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dotenv类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadDotEnv
private function loadDotEnv()
{
if (getenv("APP_ENV") !== "production") {
$dotenv = new Dotenv(__DIR__ . "/..");
$dotenv->load();
}
}
示例2: setUp
public function setUp()
{
$dotenv = new Dotenv(__DIR__ . '/../');
$dotenv->load();
$this->guzzle = m::mock(Client::class);
$this->endpoint = getenv('MAILCHIMP_ENDPOINT');
}
示例3: loadEnv
/**
* Load Dotenv to grant getenv() access to environment variables in .env file.
*/
public function loadEnv()
{
if (!getenv('APP_ENV')) {
$dotenv = new Dotenv(__DIR__ . '/../');
$dotenv->load();
}
}
示例4: __invoke
/**
* Update wp-cli.yml with settings from .env files
*
* ## OPTIONS
*
* <environment>
* : The name of the environment to set. Typically matched by a .env-<environemnt> file in the project root
*
* @param $args
* @param $assocArgs
*
* @when before_wp_load
*/
public function __invoke($args, $assocArgs)
{
$environment = $args[0];
if (file_exists(WPBOOT_BASEPATH . "/.env")) {
$dotEnv = new Dotenv(WPBOOT_BASEPATH);
$dotEnv->load();
}
$file = '.env-' . $environment;
if (file_exists(WPBOOT_BASEPATH . "/{$file}")) {
$dotEnv = new Dotenv(WPBOOT_BASEPATH, $file);
$dotEnv->overload();
}
try {
$dotEnv = new Dotenv(__DIR__);
$dotEnv->required('wppath');
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
return;
}
$runner = WP_CLI::get_runner();
$ymlPath = $runner->project_config_path;
$yaml = new Yaml();
$config = $yaml->parse(file_get_contents($ymlPath));
$config['path'] = $_ENV['wppath'];
$config['environment'] = $environment;
$dumper = new Dumper();
file_put_contents($ymlPath, $dumper->dump($config, 2));
}
示例5: loadDotenv
/**
* use vlucas dotenv to access the .env file
**/
protected function loadDotenv()
{
if (getenv('APP_ENV') !== 'production') {
$dotenv = new Dotenv(__DIR__);
$dotenv->load();
}
}
示例6: __construct
/**
* HttpHelper constructor.
*/
public function __construct()
{
$this->guzzle = new Client();
$dotenv = new Dotenv(__DIR__ . '/../');
$dotenv->load();
$dotenv->required(['API_USERNAME', 'API_PASSWORD', 'SONAR_URL'])->notEmpty();
}
示例7: setUpBeforeClass
public static function setUpBeforeClass()
{
if (file_exists(__DIR__ . '/../.env')) {
$dotenv = new Dotenv(__DIR__ . '/../');
$dotenv->load();
}
}
示例8: setUp
protected function setUp()
{
$dotenv = new Dotenv(__DIR__ . '/../');
$dotenv->load();
$uri = getenv('DATABASE_SERVER');
$this->client = new Client(['base_uri' => "http://" . $uri]);
}
示例9: __construct
public function __construct(string $configDir = __DIR__ . '/../../../../../', bool $isSandbox = false, string $configFile = '.env')
{
$config = new Dotenv($configDir, $configFile);
$config->load();
$config->required(['YANDEX_LOGIN', 'DIRECT_API_TOKEN', 'DIRECT_API_MASTER_TOKEN', 'DIRECT_API_SANDBOX_MASTER_TOKEN', 'DIRECT_ACCEPT_LANGUAGE']);
$this->sandbox = $isSandbox;
}
示例10: loadEnv
/**
* Load Dotenv to grant getenv() access to environment variables in .env file
*
* @return Values
*/
protected static function loadEnv()
{
if (!getenv("APP_ENV")) {
$dotenv = new Dotenv($_SERVER['DOCUMENT_ROOT']);
$dotenv->load();
}
}
示例11: setUp
protected function setUp()
{
parent::setUp();
file_put_contents(__DIR__ . '/../fixtures/data/.env', "test=test\ntestTrue=true\ntestFalse=false\ntestNull=null\ntestEmpty");
$dotenv = new Dotenv(__DIR__ . '/../fixtures/data/');
$dotenv->load();
}
示例12: loadenv
/**
* use vlucas dotenv to access the .env file
**/
public static function loadenv()
{
if (getenv('APP_ENV') !== 'production') {
$dotenv = new Dotenv(__DIR__);
$dotenv->load();
}
}
示例13: createDatabase
protected static function createDatabase()
{
if (empty(getenv('PGSQL_HOST')) && file_exists(__DIR__ . '/../../.env')) {
$dotenv = new Dotenv(__DIR__ . '/../../');
$dotenv->load();
}
if (empty(getenv('PGSQL_HOST')) || empty(getenv('PGSQL_USER'))) {
throw new \RuntimeException('Create a .env file with PGSQL_HOST, PGSQL_USER, and PGSQL_PASS to run this test.');
}
$pass = getenv('PGSQL_PASS') ? getenv('PGSQL_PASS') : '';
$pdo = new \PDO('pgsql:host=' . getenv('PGSQL_HOST'), getenv('PGSQL_USER'), $pass);
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
self::$connection = DriverManager::getConnection(['driver' => 'pdo_pgsql', 'pdo' => $pdo, 'dbname' => 'public']);
self::$connection->query('drop schema public cascade');
self::$connection->query('create schema public');
self::$connection->query('CREATE TABLE extended_data_objects (
id SERIAL PRIMARY KEY,
"isDeleted" BOOLEAN NOT NULL DEFAULT FALSE,
"myColumn" VARCHAR(255) NOT NULL,
"myNullableColumn" INT NULL DEFAULT NULL,
"otherDataObjectId" INT NULL
)');
self::$connection->query('CREATE TABLE other_data_objects (
id SERIAL PRIMARY KEY,
"isDeleted" BOOLEAN NOT NULL DEFAULT FALSE,
"name" VARCHAR(255) NOT NULL,
"extendedDataObjectId" INT NULL REFERENCES extended_data_objects (id)
)');
self::$connection->query('CREATE TABLE extended_other_rel (
"extendedDataObjectId" INT NOT NULL REFERENCES extended_data_objects (id),
"otherDataObjectId" INT NOT NULL REFERENCES other_data_objects (id)
)');
}
示例14: loadenv
/**
* load environment parameters
* @return resource
*/
public static function loadenv()
{
if (!getenv('APP_ENV') == 'production') {
$dotenv = new Dotenv($_SERVER['DOCUMENT_ROOT']);
$dotenv->load();
}
}
示例15: __construct
public function __construct()
{
$dotenv = new Dotenv(__DIR__ . "/../");
$dotenv->load();
$dotenv->required("MYSQL_PASSWORD");
$this->climate = new CLImate();
}