Skip to content

Commit

Permalink
Made check-environment.php more verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmaron committed May 6, 2011
1 parent a3c8fa7 commit 6dda0e4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 28 deletions.
64 changes: 38 additions & 26 deletions demos/Zend/Service/LiveDocx/check-environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@

// -----------------------------------------------------------------------------

printf('%sEnvironment Checker for Zend Framework LiveDocx Component%s%s', PHP_EOL, PHP_EOL, PHP_EOL);
echo PHP_EOL;

Helper::printLine('Environment Checker for Zend Framework LiveDocx Component' . PHP_EOL . PHP_EOL);

Helper::printLine('If requested by technical support, please send the entire output of this script to the support engineers. The information contained within is vital to debug your environment. Thank you.' . PHP_EOL . PHP_EOL);

// -----------------------------------------------------------------------------

Helper::printCheckEnvironmentLine($counter, sprintf('Checking OS (%s)', PHP_OS), TEST_PASS);
Helper::printLineToc($counter, sprintf('Checking OS (%s)', PHP_OS), TEST_PASS);

$counter++;

Expand All @@ -53,13 +57,13 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, sprintf('Checking PHP version (%s)', PHP_VERSION), $result);
Helper::printLineToc($counter, sprintf('Checking PHP version (%s)', PHP_VERSION), $result);

$counter++;

// -----------------------------------------------------------------------------

Helper::printCheckEnvironmentLine($counter, sprintf('Checking memory limit (%s)', ini_get('memory_limit')), TEST_PASS);
Helper::printLineToc($counter, sprintf('Checking memory limit (%s)', ini_get('memory_limit')), TEST_PASS);

$counter++;

Expand All @@ -72,7 +76,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, 'Checking HTTP stream wrapper', $result);
Helper::printLineToc($counter, 'Checking HTTP stream wrapper', $result);

$counter++;

Expand All @@ -85,7 +89,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, 'Checking HTTPS stream wrapper', $result);
Helper::printLineToc($counter, 'Checking HTTPS stream wrapper', $result);

$counter++;

Expand All @@ -98,7 +102,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, 'Checking Zend Framework path', $result);
Helper::printLineToc($counter, 'Checking Zend Framework path', $result);

$counter++;

Expand All @@ -111,23 +115,27 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, sprintf('Checking Zend Framework version (%s)', Version::VERSION), $result);
Helper::printLineToc($counter, sprintf('Checking Zend Framework version (%s)', Version::VERSION), $result);

$counter++;

// -----------------------------------------------------------------------------

if (extension_loaded('openssl')) {
$result = TEST_PASS;
$version = OPENSSL_VERSION_TEXT;
$result = TEST_PASS;
} else {
$result = TEST_FAIL;
$failed = true;
$version = 'N/A';
$result = TEST_FAIL;
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, 'Checking OpenSSL extension', $result);
Helper::printLineToc($counter, sprintf('Checking OpenSSL extension (%s)', $version), $result);

$counter++;

unset($version);

// -----------------------------------------------------------------------------

if (extension_loaded('soap')) {
Expand All @@ -137,7 +145,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, 'Checking SOAP extension', $result);
Helper::printLineToc($counter, 'Checking SOAP extension', $result);

$counter++;

Expand All @@ -150,7 +158,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, 'Checking DOM extension', $result);
Helper::printLineToc($counter, 'Checking DOM extension', $result);

$counter++;

Expand All @@ -163,23 +171,27 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, 'Checking SimpleXML extension', $result);
Helper::printLineToc($counter, 'Checking SimpleXML extension', $result);

$counter++;

// -----------------------------------------------------------------------------

if (extension_loaded('libxml')) {
$result = TEST_PASS;
$version = LIBXML_DOTTED_VERSION;
$result = TEST_PASS;
} else {
$result = TEST_FAIL;
$failed = true;
$version = 'N/A';
$result = TEST_FAIL;
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, 'Checking libXML extension', $result);
Helper::printLineToc($counter, sprintf('Checking libXML extension (%s)', $version), $result);

$counter++;

unset($version);

// -----------------------------------------------------------------------------

$httpClient->setUri(GEOIP_SERVICE_URI);
Expand All @@ -197,11 +209,11 @@

$simplexml = new SimpleXMLElement($httpResponse->getBody());
foreach ($keys as $key => $value) {
Helper::printCheckEnvironmentLine($counter, sprintf('Checking your %s (%s)', $keys[$key], $simplexml->$key), TEST_PASS);
Helper::printLineToc($counter, sprintf('Checking your %s (%s)', $keys[$key], $simplexml->$key), TEST_PASS);
$counter++;
}
} else {
Helper::printCheckEnvironmentLine($counter, 'Checking your geo data', TEST_FAIL);
Helper::printLineToc($counter, 'Checking your geo data', TEST_FAIL);
$failed = true;
}

Expand All @@ -220,7 +232,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, sprintf('Checking backend WSDL (%01.2fs)', $duration), $result);
Helper::printLineToc($counter, sprintf('Checking backend WSDL (%01.2fs)', $duration), $result);

$counter++;

Expand All @@ -234,7 +246,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, 'Checking backend credentials are defined', $result);
Helper::printLineToc($counter, 'Checking backend credentials are defined', $result);

$counter++;

Expand Down Expand Up @@ -263,7 +275,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, sprintf('Logging into backend service (%01.2fs)', $duration), $result);
Helper::printLineToc($counter, sprintf('Logging into backend service (%01.2fs)', $duration), $result);

$counter++;

Expand All @@ -285,7 +297,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, sprintf('[PREMIUM] Checking backend WSDL (%01.2fs)', $duration), $result);
Helper::printLineToc($counter, sprintf('[PREMIUM] Checking backend WSDL (%01.2fs)', $duration), $result);

$counter++;
}
Expand Down Expand Up @@ -322,7 +334,7 @@
$failed = true;
}

Helper::printCheckEnvironmentLine($counter, sprintf('[PREMIUM] Logging into backend service (%01.2fs)', $duration), $result);
Helper::printLineToc($counter, sprintf('[PREMIUM] Logging into backend service (%01.2fs)', $duration), $result);

$counter++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,15 @@ public static function printLine($str)
}

/**
* Print result line in check-environment.php script
* Print result line like in a table of contents i.e.:
*
* n: XXX YYY ZZZ....ZZZ
*
* @param $counter
* @param $testString
* @param $testResult
*/
public static function printCheckEnvironmentLine($counter, $testString, $testResult)
public static function printLineToc($counter, $testString, $testResult)
{
$lineLength = self::LINE_LENGTH;

Expand Down

0 comments on commit 6dda0e4

Please sign in to comment.