Skip to content

Commit

Permalink
Merge pull request #19 from open-sausages/pulls/1.0/environment-env
Browse files Browse the repository at this point in the history
Update to use new Environment::getenv() API
  • Loading branch information
flamerohr authored Oct 24, 2017
2 parents 17b8266 + 8e993d0 commit 234dff7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions bin/serve
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<?php

// Serve always hosts from the root
use SilverStripe\Core\Environment;

define('BASE_URL', '');

// Autoload
Expand All @@ -22,24 +24,24 @@ $options = getopt(null, [ 'host:', 'port:', 'hash:', 'bootstrap-file:' ]);

if (!empty($options['host'])) {
$host = $options['host'];
} elseif (getenv('SERVE_HOST')) {
$host = getenv('SERVE_HOST');
} elseif (Environment::getEnv('SERVE_HOST')) {
$host = Environment::getEnv('SERVE_HOST');
} else {
$host = '0.0.0.0';
}

if (!empty($options['port'])) {
$port = $options['port'];
} elseif (getenv('SERVE_PORT')) {
$port = getenv('SERVE_PORT');
} elseif (Environment::getEnv('SERVE_PORT')) {
$port = Environment::getEnv('SERVE_PORT');
} else {
$port = '8080';
}

if (!empty($options['bootstrap-file'])) {
$bootstrapFile = $options['bootstrap-file'];
} elseif (getenv('SERVE_BOOTSTRAP_FILE')) {
$bootstrapFile = getenv('SERVE_BOOTSTRAP_FILE');
} elseif (Environment::getEnv('SERVE_BOOTSTRAP_FILE')) {
$bootstrapFile = Environment::getEnv('SERVE_BOOTSTRAP_FILE');
} else {
$bootstrapFile = null;
}
Expand Down
6 changes: 4 additions & 2 deletions code/server-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
* framework.
*/

use SilverStripe\Core\Environment;

require_once 'constants.php';
require_once BASE_PATH . '/vendor/autoload.php';

// Include a bootstrap file (e.g. if you need extra settings to get a module started)
if (getenv('SERVE_BOOTSTRAP_FILE')) {
require_once getenv('SERVE_BOOTSTRAP_FILE');
if (Environment::getEnv('SERVE_BOOTSTRAP_FILE')) {
require_once Environment::getEnv('SERVE_BOOTSTRAP_FILE');
}

$uri = urldecode(
Expand Down

0 comments on commit 234dff7

Please sign in to comment.