Skip to content

Commit

Permalink
Improved messaging for .\config\app-settings.php not found error and …
Browse files Browse the repository at this point in the history
…also now logging the error details via error_log()

Bug Fix: added missing $c parameter to callable for setting the 'vespula_auth' item (for production environments) in the container in .\config\dependencies-dist.php
  • Loading branch information
rotexdegba committed Sep 25, 2017
1 parent 6f7c6c2 commit 2e90447
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions public/index-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function s3MVC_PrependAction2ActionMethodName($action_method_name) {
$app_settings_dist_file_path_rel = '.'.DIRECTORY_SEPARATOR."config". DIRECTORY_SEPARATOR.'app-settings-dist.php';

$app_settings_file_missing_error_page_content = <<<END
<h1>ERROR: <strong>`$app_settings_file_path_rel`</strong> not found!</h1>
<p>
<strong>ERROR: `$app_settings_file_path_rel`</strong> not found!<br><br>
Please copy <strong>`$app_settings_dist_file_path_rel`</strong> to
<strong>`$app_settings_file_path_rel`</strong> and configure
<strong>`$app_settings_file_path_rel`</strong> for your
Expand All @@ -101,29 +101,14 @@ function s3MVC_PrependAction2ActionMethodName($action_method_name) {

if( s3MVC_GetCurrentAppEnvironment() !== S3MVC_APP_ENV_DEV ) {

// We are not in a dev environment.

// 1. Make error message to be sent to the client less detailed
// We are not in a dev environment.
// Make error message to be sent to the client less detailed
$app_settings_file_missing_error_page_content = <<<END
<h1>SlimPHP 3 Skeleton MVC App Configuration Error</h1>
<p>
Please check server log file for details.
<br>Goodbye!!!
</p>
END;

// 2. Write full message to log via error_log(...)
// http://php.net/manual/en/function.error-log.php
$log_message = "ERROR:`$app_settings_file_path_rel`not found."
. " Please copy `$app_settings_dist_file_path_rel` to `$app_settings_file_path_rel` and"
. " configure `$app_settings_file_path_rel` for your application's current environment.";

error_log ( $log_message , 0 ); // message is sent to PHP's system logger,
// using the Operating System's system logging mechanism
// or a file, depending on what the error_log configuration
// directive is set to.

error_log ( $log_message , 4 ); // message is sent directly to the SAPI logging handler.
}

$app_settings_file_missing_error_page = <<<END
Expand All @@ -134,7 +119,7 @@ function s3MVC_PrependAction2ActionMethodName($action_method_name) {
body{
margin:0;
padding:30px;
font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;
font:14px/1.5 Helvetica,Arial,Verdana,sans-serif;
}
h1{
margin:0;
Expand All @@ -145,11 +130,25 @@ function s3MVC_PrependAction2ActionMethodName($action_method_name) {
</style>
</head>
<body>
<h1>SlimPHP 3 Skeleton MVC App Configuration Error</h1>
$app_settings_file_missing_error_page_content
</body>
</html>
END;
echo $app_settings_file_missing_error_page;
echo $app_settings_file_missing_error_page;

// Write full message to log via error_log(...)
// http://php.net/manual/en/function.error-log.php
$log_message = "ERROR: `$app_settings_file_path_rel` not found."
. " Please copy `$app_settings_dist_file_path_rel` to `$app_settings_file_path_rel` and"
. " configure `$app_settings_file_path_rel` for your application's current environment.";

error_log ( $log_message , 0 ); // message is sent to PHP's system logger,
// using the Operating System's system logging mechanism
// or a file, depending on what the error_log configuration
// directive is set to.

error_log ( $log_message , 4 ); // message is sent directly to the SAPI logging handler.
exit;
}

Expand Down

0 comments on commit 2e90447

Please sign in to comment.