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"; } }
/** * @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; }
public function setUp() { \Dotenv::load(__DIR__ . '/../'); $app = new \Laravel\Lumen\Application(realpath(__DIR__ . '/../')); $app->withFacades(); $this->model = 'QueryParser\\Tests\\BaseModel'; }
public function __construct($path, $file = 'config.php') { \Dotenv::load($path); if (file_exists($path . $file)) { $this->config = (include $path . $file); } }
/** * 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; }
/** * 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; }
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']); }
/** * 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']); }
/** * @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); }
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(); }
/** * 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); }
/** * 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; }
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(); }
/** * 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"); } }
/** * 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')); } }
function useFacebookCredentialsOf($account = 'EVC') { $accounts = explode(',', getenv('FACEBOOK_APPS')); foreach ($accounts as $key => $a) { Dotenv::required(array(strtoupper($a) . '_FACEBOOK_APP_ID', strtoupper($a) . '_FACEBOOK_API_SECRET', strtoupper($a) . '_FACEBOOK_ACCESS_TOKEN', strtoupper($a) . '_FACEBOOK_ACCESS_SECRET')); switch (strtolower($account)) { case strtolower($a): return array('CONSUMER_KEY' => getenv($a . '_FACEBOOK_APP_ID'), 'CONSUMER_SECRET' => getenv($a . '_FACEBOOK_API_SECRET'), 'ACCESS_TOKEN' => getenv($a . '_FACEBOOK_ACCESS_TOKEN'), 'ACCESS_SECRET' => getenv($a . '_FACEBOOK_ACCESS_SECRET')); break; } } }
/** * Register the config provider and load the default configs * * @param Application $app * * @return void */ protected function registerConfigs(Application $app) { $base = $app['path.base']; if (file_exists("{$base}/.env")) { $dotenv = \Dotenv::load($base); } $preloadedVars = ['env.HTTP_CACHE_ENABLED' => $app['http_cache.enabled'], 'env.DEBUG' => $app['debug'], 'env.AUTO_REBUILD' => $app['auto_rebuild'], 'path.base' => $base]; $envVars = $_ENV; foreach ($envVars as $k => $v) { $preloadedVars["env.{$k}"] = $v; } $app->register(new \Igorw\Silex\ConfigServiceProvider("{$base}/config/site.yaml", $preloadedVars)); }
public function envLoad($path = null) { if (empty($path)) { $path = base_path(); } $dotenv = \Dotenv::load($path); $this->gitHost = str_replace("\"", "", getenv('GITLAB_HOST')); $this->gitToken = str_replace("\"", "", getenv('GITLAB_TOKEN')); $this->hookUrl = str_replace("\"", "", getenv('HOOK_URL')); $debug = str_replace("\"", "", getenv('APP_DEBUG')); if (strtolower($debug) === 'true') { $this->debug = true; } $verbose = str_replace("\"", "", getenv('APP_VERBOSE')); if (strtolower($verbose) === 'true') { $this->verbose = true; } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { /* This is necessary for frontend servers to perform cleanup after running their own unit tests */ if ($request->has('test_key')) { if (file_exists(base_path() . '/.env.testing')) { \Dotenv::load(base_path(), '.env.testing'); } $inputKey = $request->input('test_key', str_random(32)); $envKey = env('TEST_KEY', str_random(32)); if ($inputKey != $envKey) { throw new \FatalErrorException('Get outta here.'); } } return $next($request); }
public function setUp() { parent::setUp(); // Load Dotenv Dotenv::load(__DIR__); // Set Laravel configuration parameters Config::set('elvis.api_endpoint_uri', getenv('ELVIS_API_ENDPOINT_URI')); Config::set('elvis.username', getenv('ELVIS_USERNAME')); Config::set('elvis.password', getenv('ELVIS_PASSWORD')); // Get session Id to user in the queries $this->sessionId = Elvis::login(); // Upload a randon file to Elvis for various tests $temporaryFilename = tempnam("/tmp", "ElvisTest"); // Create a file and store asset id $create = Elvis::create($this->sessionId, $temporaryFilename); $this->assetId = $create->id; // Remove temporary file unlink($temporaryFilename); }
<?php require_once __DIR__ . '/../vendor/autoload.php'; Dotenv::load(__DIR__ . '/../'); /* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | Here we will load the environment and create the application instance | that serves as the central piece of this framework. We'll use this | application as an "IoC" container and router for this framework. | */ $app = new Laravel\Lumen\Application(realpath(__DIR__ . '/../')); $app->withFacades(); $app->withEloquent(); /* |-------------------------------------------------------------------------- | Register Container Bindings |-------------------------------------------------------------------------- | | Now we will register a few bindings in the service container. We will | register the exception handler and the console kernel. You may add | your own bindings here if you like or you can make another file. | */ $app->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class); $app->singleton(Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class); /* |--------------------------------------------------------------------------
<?php require dirname(__FILE__) . "/../vendor/autoload.php"; Dotenv::load(__DIR__ . "/../"); use SoftLayer\Messaging; define('QUEUE_ACCOUNT', getenv('QUEUE_ACCOUNT')); define('QUEUE_USERNAME', getenv('QUEUE_USERNAME')); define('QUEUE_API_KEY', getenv('QUEUE_API_KEY')); define('WAIT', 5); abstract class BaseTest extends PHPUnit_Framework_TestCase { public static $messaging; public static $queues = array(); public static $topics = array(); public static function setUpBeforeClass() { self::$messaging = new Messaging(); self::$messaging->authenticate(QUEUE_ACCOUNT, QUEUE_USERNAME, QUEUE_API_KEY); self::$queues = array(); self::$topics = array(); } public static function queueName() { array_unshift(self::$queues, "testQueue_" . rand(0, 99999)); return self::$queues[0]; } public static function topicName() { array_unshift(self::$topics, "testTopic_" . rand(0, 99999)); return self::$topics[0]; }
<?php date_default_timezone_set('UTC'); // If there is an env file, then load it, so that the configs can use them if (build_path([__DIR__, '..', '.env'], true)) { Dotenv::load(build_path([__DIR__, '..'])); } // Path to config file $config_file = build_path([__DIR__, '..', 'config', 'generator.php'], true); // Read the config file if there is one, otherwise set to empty array $config = (array) ($config_file ? require $config_file : []); // Return a new generator return new Spinen\ConnectWise\Generator\Generator($config);
<?php require 'vendor/autoload.php'; function out($message) { echo "\n{$message}\n"; } Dotenv::load(__DIR__); $backup_directory_today = "/backup/" . date('Y-m-d'); mkdir($backup_directory_today); $issue_database_filename = $backup_directory_today . "/issue_database.sql.gz"; // Archive Lendia database $db_host = getenv('DB_HOST'); $db_database = getenv('DB_DATABASE'); $db_user = getenv('DB_USERNAME'); $db_pass = getenv('DB_PASSWORD'); $dump_command = "mysqldump --host={$db_host} --user={$db_user} --password={$db_pass} {$db_database} | gzip > {$issue_database_filename}"; out("Running Issue database backup"); out($dump_command); exec($dump_command);
| The first thing we will do is create a new Laravel application instance | which serves as the "glue" for all the components of Laravel, and is | the IoC container for the system binding all of the various parts. | */ $app = new Illuminate\Foundation\Application(realpath(__DIR__ . '/../')); /* |-------------------------------------------------------------------------- | Bind Important Interfaces |-------------------------------------------------------------------------- | | Next, we need to bind some important interfaces into the container so | we will be able to resolve them when needed. The kernels serve the | incoming requests to this application from both the web and CLI. | */ $app->singleton(Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class); $app->singleton(Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class); $app->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class); Dotenv::required(['TWILIO_ACCOUNT_SID', 'TWILIO_AUTH_TOKEN', 'TWILIO_SENDING_NUMBER']); /* |-------------------------------------------------------------------------- | Return The Application |-------------------------------------------------------------------------- | | This script returns the application instance. The instance is given to | the calling script so we can separate the building of the instances | from the actual running of the application and sending responses. | */ return $app;
<?php /* |-------------------------------------------------------------------------- | Detect The Application Environment |-------------------------------------------------------------------------- | | Laravel takes a dead simple approach to your application environments | so you can just specify a machine name for the host that matches a | given environment, then we will automatically detect it for you. | */ $env = $app->detectEnvironment(function () { $environmentPath = __DIR__ . '/../.env'; $setEnv = trim(file_get_contents($environmentPath)); if (file_exists($environmentPath)) { putenv("APP_ENV={$setEnv}"); if (getenv('APP_ENV') && file_exists(__DIR__ . '/../.' . getenv('APP_ENV') . '.env')) { Dotenv::load(__DIR__ . '/../', '.' . getenv('APP_ENV') . '.env'); } } });
<?php ini_set('memory_limit', '2048M'); use Alchemy\Zippy\Zippy; use Aws\S3\S3Client; use League\Flysystem\AwsS3v2\AwsS3Adapter; use League\Flysystem\Filesystem; Dotenv::load(__DIR__, '.env.deploy'); /** * This is project's console commands configuration for Robo task runner. * * @see http://robo.li/ */ class RoboFile extends \Robo\Tasks { /** * Build task. * * @return bool */ public function build() { $this->say('Build task'); $envFile = __DIR__ . '/.env.dist'; if (!file_exists($envFile)) { $this->yell(sprintf('The environment "%s" file does not exist!', $envFile)); return false; } $buildPath = $this->getBuildPath(); $filename = 'api_' . time() . '.zip'; $this->say("Creating archive {$filename} in {$buildPath}");
<?php // Path to directory that contains the entire app define('ROOT_DIR', realpath(__DIR__ . '/..')); // Loads all the environment variables from ROOT_DIR/.env Dotenv::load(ROOT_DIR); // Set the default timezone <http://php.net/manual/en/timezones.php> NConfig::setTimezone(getenv('TIMEZONE')); // Legacy defines. Environment variables should be used moving forward define('APP_NAME', 'nterchange'); define('APP_DIR', APP_NAME); define('CACHE_DIR', realpath(ROOT_DIR . '/var')); define('EXTERNAL_CACHE', false); // no trailing slash define('ASSET_DIR', realpath(ROOT_DIR . '/app')); define('DOCUMENT_ROOT', ROOT_DIR . '/public_html'); define('ENVIRONMENT', getenv('ENVIRONMENT')); define('SECURE_SITE', false); define('ADMIN_SITE', APP_DIR . '/'); define('ADMIN_URL', false); // this is false by default, or the full domain of the admin (http://admin.example.com/) define('SITE_DRAFTS', true); define('SITE_PERMISSIONS', true); define('SITE_WORKFLOW', false); define('SITE_PRINTABLE', true); define('SITE_AUDIT_TRAIL', true); define('SITE_TIME_ZONE', 'MST7MDT'); // string id of the site's time zone (eg. MST7MDT) - this is case-sensitive! define('ERROR_EMAIL', '*****@*****.**'); define('CURRENT_SITE', (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']) == 443 ? 'secure' : 'public'); define('SITE_NAME', getenv('SITE_NAME'));
<?php $root_dir = dirname(__DIR__); $webroot_dir = $root_dir . '/web'; /** * Use Dotenv to set required environment variables and load .env file in root */ if (file_exists($root_dir . '/.env')) { Dotenv::load($root_dir); } Dotenv::required(array('DB_NAME', 'DB_USER', 'DB_PASSWORD', 'WP_HOME', 'WP_SITEURL')); /** * Set up our global environment constant and load its config first * Default: development */ define('WP_ENV', getenv('WP_ENV') ? getenv('WP_ENV') : 'development'); $env_config = dirname(__FILE__) . '/environments/' . WP_ENV . '.php'; if (file_exists($env_config)) { require_once $env_config; } /** * Custom Content Directory */ define('CONTENT_DIR', '/app'); define('WP_CONTENT_DIR', $webroot_dir . CONTENT_DIR); define('WP_CONTENT_URL', WP_HOME . CONTENT_DIR); /** * DB settings */ define('DB_CHARSET', 'utf8'); define('DB_COLLATE', '');
<?php define('APP_START', microtime(true)); define('APP_PATH', realpath(__DIR__ . '/..') . '/'); /* |-------------------------------------------------------------------------- | Register The Composer Auto Loader |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader | for our application. We just need to utilize it! We'll require it | into the script here so that we do not have to worry about the | loading of any our classes "manually". Feels great to relax. | */ require APP_PATH . 'vendor/autoload.php'; try { Dotenv::load(APP_PATH); } catch (InvalidArgumentException $e) { // }