本文整理汇总了PHP中Dotenv\Dotenv::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Dotenv::load方法的具体用法?PHP Dotenv::load怎么用?PHP Dotenv::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dotenv\Dotenv
的用法示例。
在下文中一共展示了Dotenv::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseEnvironmentVariables
/**
* Parses environment file
*/
protected function parseEnvironmentVariables()
{
if ($this->allowOverloading) {
$this->dotEnv->overload();
} else {
$this->dotEnv->load();
}
}
示例2: loadEnv
/**
* Use Dotenv to set required environment variables from .env file in root
*/
protected function loadEnv()
{
try {
$this->dotenv->load();
$this->dotenv->required($this->required);
} catch (\InvalidArgumentException $e) {
// Assuming env data is set by server
}
}
示例3: __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();
}
示例4: loadenv
/**
* load environment parameters
* @return resource
*/
public static function loadenv()
{
if (!getenv('APP_ENV') == 'production') {
$dotenv = new Dotenv($_SERVER['DOCUMENT_ROOT']);
$dotenv->load();
}
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
if (file_exists(__DIR__ . '/../.env')) {
$dotenv = new Dotenv(__DIR__ . '/../');
$dotenv->load();
}
}
示例6: setUp
public function setUp()
{
$dotenv = new Dotenv(__DIR__ . '/../');
$dotenv->load();
$this->guzzle = m::mock(Client::class);
$this->endpoint = getenv('MAILCHIMP_ENDPOINT');
}
示例7: loadDotEnv
private function loadDotEnv()
{
if (getenv("APP_ENV") !== "production") {
$dotenv = new Dotenv(__DIR__ . "/..");
$dotenv->load();
}
}
示例8: 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();
}
}
示例9: 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();
}
示例10: loadenv
/**
* use vlucas dotenv to access the .env file
**/
public static function loadenv()
{
if (getenv('APP_ENV') !== 'production') {
$dotenv = new Dotenv(__DIR__);
$dotenv->load();
}
}
示例11: loadDotenv
/**
* use vlucas dotenv to access the .env file
**/
protected function loadDotenv()
{
if (getenv('APP_ENV') !== 'production') {
$dotenv = new Dotenv(__DIR__);
$dotenv->load();
}
}
示例12: 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)
)');
}
示例13: __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));
}
示例14: setUp
protected function setUp()
{
$dotenv = new Dotenv(__DIR__ . '/../');
$dotenv->load();
$uri = getenv('DATABASE_SERVER');
$this->client = new Client(['base_uri' => "http://" . $uri]);
}
示例15: __construct
public function __construct()
{
$dotenv = new Dotenv(__DIR__ . "/../");
$dotenv->load();
$dotenv->required("MYSQL_PASSWORD");
$this->climate = new CLImate();
}