当前位置: 首页>>代码示例>>PHP>>正文


PHP Dotenv::required方法代码示例

本文整理汇总了PHP中Dotenv\Dotenv::required方法的典型用法代码示例。如果您正苦于以下问题:PHP Dotenv::required方法的具体用法?PHP Dotenv::required怎么用?PHP Dotenv::required使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dotenv\Dotenv的用法示例。


在下文中一共展示了Dotenv::required方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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
     }
 }
开发者ID:mrgrain,项目名称:autobahn-config,代码行数:12,代码来源:WordPress.php

示例2: __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));
 }
开发者ID:eriktorsner,项目名称:wp-bootstrap,代码行数:41,代码来源:SetEnv.php

示例3: __construct

 public function __construct()
 {
     $dotenv = new Dotenv(__DIR__ . "/../");
     $dotenv->load();
     $dotenv->required("MYSQL_PASSWORD");
     $this->climate = new CLImate();
 }
开发者ID:sonarsoftware,项目名称:freeradius_genie,代码行数:7,代码来源:Genie.php

示例4: __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;
 }
开发者ID:perf2k2,项目名称:direct,代码行数:7,代码来源:Connection.php

示例5: __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();
 }
开发者ID:sonarsoftware,项目名称:customer_portal_framework,代码行数:10,代码来源:HttpHelper.php

示例6: register

 /**
  * @inheritdoc
  */
 public function register(Container $container)
 {
     $container['dotenv'] = function (Container $container) {
         $dotenv = new Dotenv(__DIR__ . '/../..');
         $dotenv->load();
         // Requiring Variables to be Set
         $dotenv->required('APP_DEBUG');
         $this->addEnvVarsToApp($container);
     };
 }
开发者ID:anolilab,项目名称:howtoclearmybrowsercache,代码行数:13,代码来源:DotEnvServiceProvider.php

示例7: getConnection

 public final function getConnection()
 {
     if ($this->conn === null) {
         $dotenv = new Dotenv(__DIR__ . '/..');
         $dotenv->load();
         $dotenv->required(['DB_DATABASE'])->notEmpty();
         $this->conn = $this->createDefaultDBConnection($this->pdo, getenv('DB_DATABASE'));
     }
     return $this->conn;
 }
开发者ID:andela-oogunjimi,项目名称:Potato-ORM,代码行数:10,代码来源:UserTest.php

示例8: createApplication

 /**
  * @return Application
  * @throws \Exception
  */
 public function createApplication()
 {
     if (file_exists(__DIR__ . '/../.env')) {
         $dotenv = new Dotenv(__DIR__ . '/../');
         $dotenv->load();
         $dotenv->required('APP_DEBUG')->allowedValues([true, false]);
         $dotenv->required('APP_ENV')->allowedValues(['production', 'development', 'staging', 'dev', 'test']);
         $dotenv->required('APP_TWIG_AUTO_RELOAD')->allowedValues([true, false]);
     }
     if (!file_exists(__DIR__ . '/../app/config.' . env('APP_ENV', 'test') . '.php')) {
         throw new \Exception('app/config. ' . env('APP_ENV', 'test') . '.php not found');
     }
     $containerBuilder = new ContainerBuilder();
     require __DIR__ . '/../web/container.' . env('APP_ENV', 'production') . '.php';
     $app = new Application($containerBuilder, require __DIR__ . '/../app/config.' . env('APP_ENV', 'test') . '.php');
     require __DIR__ . '/../web/services.' . env('APP_ENV', 'production') . '.php';
     require __DIR__ . '/../web/middleware.' . env('APP_ENV', 'production') . '.php';
     require __DIR__ . '/../web/routes.php';
     return $app;
 }
开发者ID:praswicaksono,项目名称:silex-skeleton,代码行数:24,代码来源:CreateApplicationTrait.php

示例9: apply

 /**
  * @inheritDoc
  */
 public function apply(Injector $injector)
 {
     $injector->alias('Equip\\Auth\\Token\\ExtractorInterface', 'Equip\\Auth\\Token\\QueryExtractor');
     $injector->define('Equip\\Auth\\Token\\QueryExtractor', [':parameter' => 'tk']);
     $injector->alias('Equip\\Auth\\Credentials\\ExtractorInterface', 'Equip\\Auth\\Credentials\\BodyExtractor');
     $injector->alias('Equip\\Auth\\AdapterInterface', 'Equip\\Project\\Auth\\Adapter');
     $dir = dirname(dirname(__DIR__));
     $dotenv = new Dotenv($dir);
     $dotenv->load();
     $dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS']);
 }
开发者ID:JasonBusse,项目名称:rest_scheduler,代码行数:14,代码来源:ProjectConfiguration.php

示例10: bootstrap

 /**
  * Bootstrap Dotenv.
  *
  * @param  \Conrock\Application $app
  */
 public function bootstrap(Application $app)
 {
     $path = $app->get_base_path();
     if (!file_exists($path . '/.env')) {
         throw new InvalidArgumentException('Cannot find .env file in ' . $path);
     }
     $dotenv = new Dotenv($path);
     $dotenv->load();
     $dotenv->required($app->get_required());
     if (!defined('WP_ENV')) {
         define('WP_ENV', getenv('WP_ENV') ?: 'development');
     }
 }
开发者ID:frozzare,项目名称:wp-conrock,代码行数:18,代码来源:load-dotenv.php

示例11: load

 public static function load()
 {
     $dotenv = new Dotenv(__DIR__ . '/../..');
     $dotenv->load();
     $dotenv->required(['DB_ENGINE'])->allowedValues(['sqlite']);
     switch (getenv('DB_ENGINE')) {
         case 'sqlite':
             if (self::$_sqliteConnection == null) {
                 self::$_sqliteConnection = new SqliteConnection();
             }
             return self::$_sqliteConnection;
     }
 }
开发者ID:andela-oogunjimi,项目名称:Potato-ORM,代码行数:13,代码来源:ConnectionFactory.php

示例12: requireEnv

 protected function requireEnv($parameters)
 {
     $app = \Wpbootstrap\Bootstrap::getApplication();
     $cli = $app['cli'];
     $dotEnv = new Dotenv(WPBOOT_BASEPATH);
     try {
         foreach ($parameters as $parameter) {
             $dotEnv->required($parameter);
         }
     } catch (\Exception $e) {
         $cli->warning($e->getMessage());
         return false;
     }
     return true;
 }
开发者ID:eriktorsner,项目名称:wp-bootstrap,代码行数:15,代码来源:BaseCommand.php

示例13: loadCredentials

 protected function loadCredentials()
 {
     // Check if we should use test api or not. Load appropriate credentials.
     if ($this->isvuUseTestApi == true) {
         // Use test API.
         // Test username and password are mandatory for Pirac to work.
         $this->dotEnvInstance->required(['ISVU_TEST_USERNAME', 'ISVU_TEST_PASSWORD'])->notEmpty();
         $this->isvuUsername = getenv('ISVU_TEST_USERNAME');
         $this->isvuPassword = getenv('ISVU_TEST_PASSWORD');
     } else {
         // Use production API.
         // Username and password are mandatory for Pirac to work.
         $this->dotEnvInstance->required(['ISVU_USERNAME', 'ISVU_PASSWORD'])->notEmpty();
         // Load credentials into properties.
         $this->isvuUsername = getenv('ISVU_USERNAME');
         $this->isvuPassword = getenv('ISVU_PASSWORD');
     }
 }
开发者ID:cicnavi,项目名称:pirac,代码行数:18,代码来源:Settings.php

示例14: getDbConn

 public function getDbConn()
 {
     $db = null;
     try {
         $dotenv = new Dotenv(dirname(__DIR__));
         $dotenv->load();
         $dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS']);
         try {
             $dbHost = getenv('DB_HOST');
             $dbName = getenv('DB_NAME');
             $dbUser = getenv('DB_USER');
             $dbPass = getenv('DB_PASS');
             $db = new PDO("mysql:host={$dbHost};dbname={$dbName};charset=utf8mb4", $dbUser, $dbPass);
             $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         } catch (\PDOException $e) {
             exit('Could not connect.');
         }
     } catch (Exception $e) {
         exit('Could not find a .env file.');
     }
     return $db;
 }
开发者ID:rogeriotadim,项目名称:tarefas-da-molecada,代码行数:22,代码来源:Service.php

示例15: Dotenv

<?php

/**
 * PHP version 5.6
 *
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
 */
require __DIR__ . '/../../../../../../vendor/autoload.php';
use EwalletApplication\Bridges\Pimple\EwalletConsoleContainer;
use EwalletApplication\Bridges\SymfonyConsole\EwalletApplication;
use Dotenv\Dotenv;
$environment = new Dotenv(__DIR__ . '/../../../../../../');
$environment->load();
$environment->required(['DOCTRINE_DEV_MODE', 'TWIG_DEBUG', 'SMTP_HOST', 'SMTP_PORT']);
$application = new EwalletApplication(new EwalletConsoleContainer(require __DIR__ . '/../../../../../../app/config.php'));
$application->run();
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:16,代码来源:console.php


注:本文中的Dotenv\Dotenv::required方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。