當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dotenv類代碼示例

本文整理匯總了PHP中Dotenv的典型用法代碼示例。如果您正苦於以下問題:PHP Dotenv類的具體用法?PHP Dotenv怎麽用?PHP Dotenv使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Dotenv類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetOrder

 function testGetOrder()
 {
     $dotenv = new Dotenv();
     $root = dirname(dirname(__FILE__));
     $dotenv->load($root);
     $dotenv->required(['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'APPLICATION_NAME', 'APPLICATION_VERSION']);
     $serviceUrl = "https://mws.amazonservices.com/Orders/2013-09-01";
     $config = array('ServiceURL' => $serviceUrl, 'ProxyHost' => null, 'ProxyPort' => -1, 'ProxyUsername' => null, 'ProxyPassword' => null, 'MaxErrorRetry' => 3);
     $service = new \Amazon\MWS\Orders\Orders_Client(getenv("AWS_ACCESS_KEY_ID"), getenv("AWS_SECRET_ACCESS_KEY"), getenv("APPLICATION_NAME"), getenv("APPLICATION_VERSION"), $config);
     /************************************************************************
      * Uncomment to try out Mock Service that simulates MarketplaceWebServiceOrders
      * responses without calling MarketplaceWebServiceOrders service.
      *
      * Responses are loaded from local XML files. You can tweak XML files to
      * experiment with various outputs during development
      *
      * XML files available under MarketplaceWebServiceOrders/Mock tree
      *
      ***********************************************************************/
     // $service = new MarketplaceWebServiceOrders_Mock();
     /************************************************************************
      * Setup request parameters and uncomment invoke to try out
      * sample for Get Order Action
      ***********************************************************************/
     // @TODO: set request. Action can be passed as Orders_Model_GetOrder
     $request = new \Amazon\MWS\Orders\Model\Orders_Model_GetOrderRequest(['AmazonOrderId' => '114-9172390-8828251', 'SellerId' => getenv("SELLER_ID")]);
     //		$request->setSellerId(getenv("MERCHANT_ID"));
     //		$request->setAmazonOrderId('114-9172390-8828251');
     // object or array of parameters
     /**
      * Get Get Order Action Sample
      * Gets competitive pricing and related information for a product identified by
      * the MarketplaceId and ASIN.
      *
      * @param MarketplaceWebServiceOrders_Interface $service instance of MarketplaceWebServiceOrders_Interface
      * @param mixed $request Orders_Model_GetOrder or array of parameters
      */
     try {
         $response = $service->GetOrder($request);
         echo "Service Response\n";
         echo "=============================================================================\n";
         $dom = new \DOMDocument();
         $dom->loadXML($response->toXML());
         $dom->preserveWhiteSpace = false;
         $dom->formatOutput = true;
         echo $dom->saveXML();
         echo "ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n";
     } catch (MarketplaceWebServiceOrders_Exception $ex) {
         echo "Caught Exception: " . $ex->getMessage() . "\n";
         echo "Response Status Code: " . $ex->getStatusCode() . "\n";
         echo "Error Code: " . $ex->getErrorCode() . "\n";
         echo "Error Type: " . $ex->getErrorType() . "\n";
         echo "Request ID: " . $ex->getRequestId() . "\n";
         echo "XML: " . $ex->getXML() . "\n";
         echo "ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n";
     }
 }
開發者ID:jackkam85,項目名稱:Amazon-MWS-PHP-CL,代碼行數:57,代碼來源:MarketplaceWebServiceOrders_ClientTest.php

示例2: getEnvironment

 /**
  * @return string
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function getEnvironment()
 {
     $fileSystem = new Filesystem();
     $environment = '';
     $environmentPath = app()->getBasePath() . '/.env';
     if ($fileSystem->isFile($environmentPath)) {
         $environment = trim($fileSystem->get($environmentPath));
         $envFile = app()->getBasePath() . '/.' . $environment;
         if ($fileSystem->isFile($envFile . '.env')) {
             $dotEnv = new Dotenv(app()->getBasePath() . '/', '.' . $environment . '.env');
             $dotEnv->load();
         }
     }
     return $environment;
 }
開發者ID:pongtan,項目名稱:framework,代碼行數:20,代碼來源:ConfigServiceProvider.php

示例3: setUp

 public function setUp()
 {
     \Dotenv::load(__DIR__ . '/../');
     $app = new \Laravel\Lumen\Application(realpath(__DIR__ . '/../'));
     $app->withFacades();
     $this->model = 'QueryParser\\Tests\\BaseModel';
 }
開發者ID:rlacerda83,項目名稱:lumen-api-query-parser,代碼行數:7,代碼來源:QueryParserTest.php

示例4: __construct

 public function __construct($path, $file = 'config.php')
 {
     \Dotenv::load($path);
     if (file_exists($path . $file)) {
         $this->config = (include $path . $file);
     }
 }
開發者ID:reservat,項目名稱:core,代碼行數:7,代碼來源:Config.php

示例5: GetConfig

 /**
  * Loads environment variables from the .env file in the current working directory (getcwd), and puts them in a
  * Config container.
  *
  * @return Config
  */
 public static function GetConfig()
 {
     /*
      * Load environment variables (only if we have a .env file)
      */
     $envFilename = ".env";
     $envDir = getcwd();
     $envPath = "{$envDir}/{$envFilename}";
     if (file_exists($envPath)) {
         \Dotenv::load($envDir, $envFilename);
     }
     /*
      * Make sure required environment variables are set
      */
     \Dotenv::required(array("PAYPAL_CLIENT_ID", "PAYPAL_CLIENT_SECRET", "PAYPAL_ENDPOINT_MODE", "PAYPAL_EXPERIENCE_CLI_PROFILES_DIR"));
     /*
      * Create a config object and return it
      */
     $config = new Config(getenv("PAYPAL_CLIENT_ID"), getenv("PAYPAL_CLIENT_SECRET"), getenv("PAYPAL_ENDPOINT_MODE"), getenv("PAYPAL_EXPERIENCE_CLI_PROFILES_DIR"), getenv("PAYPAL_ENABLE_LOG"), getenv("PAYPAL_LOG_FILENAME"));
     // make sure the profiles directory is valid
     if (!$config->GetProfilesDirAbsolute()) {
         die("ERROR / Could not find profiles directory.\n");
     }
     return $config;
 }
開發者ID:cullylarson,項目名稱:paypal-experience-cli,代碼行數:31,代碼來源:Setup.php

示例6: get

 /**
  * Utility method to return either an env var or a default value if the var is not set.
  *
  * @param string $key the name of the variable to get
  * @param mixed $default the default value to return if variable is not set. Default is null.
  * @param bool $required whether the var must be set. $default is ignored in this case. Default is `false`.
  * @return mixed the content of the environment variable or $default if not set
  */
 public static function get($key, $default = null, $required = false)
 {
     if ($required) {
         Dotenv::required($key);
     }
     return isset($_ENV[$key]) ? $_ENV[$key] : $default;
 }
開發者ID:maxwelldu,項目名稱:yii2-dockerized,代碼行數:15,代碼來源:DockerEnv.php

示例7: testDotEnvWithConfig

 public function testDotEnvWithConfig()
 {
     Dotenv::load(__DIR__ . '/_files/');
     $config = new Config(__DIR__ . '/_files/', 'dotenv.php');
     $this->assertEquals(getenv('MYSQL_USER'), $config->mysql['user']);
     $this->assertEquals(getenv('MYSQL_HOST'), $config->mysql['host']);
     $this->assertEquals(getenv('CUSTOM_BAR'), $config->custom['bar']);
 }
開發者ID:reservat,項目名稱:core,代碼行數:8,代碼來源:ConfigTest.php

示例8: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     if ($this->app->runningInConsole()) {
         return;
     }
     // ensure that this variables are required
     \Dotenv::required(['DB_HOST', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD']);
 }
開發者ID:muhamadsyahril,項目名稱:ecommerce-1,代碼行數:13,代碼來源:EnvironmentServiceProvider.php

示例9: getComposer

 /**
  * @return Composer
  */
 protected function getComposer()
 {
     $dir = Module::getRootDir();
     $path = $dir . '/composer.json';
     \Dotenv::setEnvironmentVariable('COMPOSER', $path);
     $factory = new Factory();
     return $factory->createComposer(new NullIO(), $path, false, $dir);
 }
開發者ID:NullRefExcep,項目名稱:yii2-core,代碼行數:11,代碼來源:ComposerController.php

示例10: boot

 function boot($rootDir, $urlDepth = 0, callable $onStartUp = null)
 {
     $rootDir = normalizePath($rootDir);
     // Initialize some settings from environment variables
     $dotenv = new Dotenv("{$rootDir}/.env");
     try {
         $dotenv->load();
     } catch (ConfigException $e) {
         echo $e->getMessage();
         return 1;
     }
     // Load the kernel's configuration.
     /** @var KernelSettings $kernelSettings */
     $kernelSettings = $this->kernelSettings = $this->injector->share(KernelSettings::class, 'app')->make(KernelSettings::class);
     $kernelSettings->isWebBased = true;
     $kernelSettings->setApplicationRoot($rootDir, $urlDepth);
     // Setup debugging (must be done before instantiating the kernel, but after instantiating its settings).
     $this->setupDebugging($rootDir);
     // Boot up the framework's kernel.
     $this->injector->execute([KernelModule::class, 'register']);
     // Boot up the framework's subsytems and the application's modules.
     /** @var KernelInterface $kernel */
     $kernel = $this->injector->make(KernelInterface::class);
     if ($onStartUp) {
         $onStartUp($kernel);
     }
     // Boot up all modules.
     try {
         $kernel->boot();
     } catch (ConfigException $e) {
         $NL = "<br>\n";
         echo $e->getMessage() . $NL . $NL;
         if ($e->getCode() == -1) {
             echo sprintf('Possile error causes:%2$s%2$s- the class name may be misspelled,%2$s- the class may no longer exist,%2$s- module %1$s may be missing or it may be corrupted.%2$s%2$s', str_match($e->getMessage(), '/from module (\\S+)/')[1], $NL);
         }
         $path = "{$kernelSettings->storagePath}/" . ModulesRegistry::REGISTRY_FILE;
         if (file_exists($path)) {
             echo "Tip: one possible solution is to remove the '{$path}' file and run 'workman' to rebuild the module registry.";
         }
     }
     // Finalize.
     if ($kernel->devEnv()) {
         $this->setDebugPathsMap($this->injector->make(ModulesRegistry::class));
     }
     return $kernel->getExitCode();
 }
開發者ID:electro-framework,項目名稱:framework,代碼行數:46,代碼來源:WebBootloader.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $m = Mapper::map(42.322639, -71.07284900000001, ['zoom' => 6, 'center' => true, 'marker' => true, 'type' => 'ROADMAP']);
     $data['census_apikey'] = \Dotenv::findEnvironmentVariable('CENSUS_APIKEY');
     $data['map'] = $m;
     $data['id'] = 'census';
     return view('map', $data);
 }
開發者ID:wfleurant,項目名稱:census,代碼行數:13,代碼來源:HomeController.php

示例12: createApplication

 /**
  * Creates the application.
  *
  * @return \Illuminate\Foundation\Application
  */
 public function createApplication()
 {
     $app = (require __DIR__ . '/../bootstrap/app.php');
     if (file_exists(dirname(__DIR__) . '/.env.test')) {
         Dotenv::load(dirname(__DIR__), '.env.test');
     }
     $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
     return $app;
 }
開發者ID:vitr,項目名稱:pulledover,代碼行數:14,代碼來源:TestCase.php

示例13: init

 public static function init()
 {
     \Dotenv::required(array('DB_CONNECTION_NAME', 'DB_DRIVER', 'DB_HOST', 'DB_CATALOG', 'DB_USERNAME', 'DB_PASSWORD', 'DB_CHARSET', 'DB_COLLATION', 'DB_PREFIX'));
     $capsule = new Capsule();
     $dcn = defined('DB_CONNECTION_NAME') ? $_ENV['DB_CONNECTION_NAME'] : 'default';
     $capsule->addConnection(array('driver' => $_ENV['DB_DRIVER'], 'host' => $_ENV['DB_HOST'], 'database' => $_ENV['DB_CATALOG'], 'username' => $_ENV['DB_USERNAME'], 'password' => $_ENV['DB_PASSWORD'], 'charset' => $_ENV['DB_CHARSET'], 'collation' => $_ENV['DB_COLLATION'], 'prefix' => $_ENV['DB_PREFIX']), $dcn);
     // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
     $capsule->bootEloquent();
 }
開發者ID:benallfree,項目名稱:makenv-eloquent-standalone,代碼行數:9,代碼來源:load.php

示例14: setUp

 /**
  * PHPUnit Setup Function
  *
  */
 public function setUp()
 {
     if (file_exists(__DIR__ . '/../.env')) {
         Dotenv::load(__DIR__ . '/../');
     }
     $this->client = new \Cjhbtn\Periscopr\Client();
     if ($this->requiresAuth && !$this->setUpAuth()) {
         $this->markTestSkipped("Authenticated test skipped - Unable to authenticate with Periscope API");
     }
 }
開發者ID:exileed,項目名稱:periscopr-api,代碼行數:14,代碼來源:BaseTest.php

示例15: _loadEnv

 /**
  * loading envs
  */
 private static function _loadEnv()
 {
     if (getenv('DB_NAME') != null && getenv('DB_NAME') != "") {
         return;
     }
     if (defined('ABSPATH')) {
         \Dotenv::load(ABSPATH);
     } else {
         \Dotenv::load(getenv('HOME'));
     }
 }
開發者ID:amarcinkowski,項目名稱:hospitalplugin,代碼行數:14,代碼來源:DoctrineBootstrap.php


注:本文中的Dotenv類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。