1.1 Default Constants

As you can see in [[installation guide|1. Install]], we have created on the begin of the index.php, main file from the system, two constants that is:

index.php

1
2
define('DEVELOPMENT', (bool) getenv("DEVELOPMENT"));
define('SHOW_ERRORS', (bool) getenv("SHOW_ERRORS"));

Both was defined in the Virtual Host as you can see below and was defined to inform us about the execution environment and the showing of errors from PHP.

VirtualHost

You can set this constants in your virtual host following these instructions in the apache virtual host space. You have the option to insert this configuration in the .htaccess file, but in this case you must to keep different files on production and development. We don't think that it is a good idea while you should be using GIT and it will cause conflicts. Anyway, it depends of yours necessities and how is you using GIT features. Feel free to invent your own way if you want it and God touch your heart.

1
2
3
4
5
6
7
<VirtualHost *:80>
    # ...

    SetEnv DEVELOPMENT true
    SetEnv SHOW_ERRORS true

    # ...

What that means?

DEVELOPMENT

It indicates that the system is running on development environment, in this way you can set some blocks of code to run only in that environment and don't have the risk to forget dump's accidentally lost in the code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
try {
    $userBo = new UserBusiness();
    $user = $userBo->get((int) $this->getParam('user', 0));

} catch(\Exception $e) {
    // If this  is running on Development environment
    // will be dispatched the function dump() which shows
    // some variable content in a white screen. In this case an Exception.
    if (DEVELOPMENT) {
        dump($e);
    }
}

SHOW_ERRORS

It indicates to the system that the errors must be shown. Actually, if you followed the recommendation to create index.php file you don't need to do anything else. Your index.php file must to be like this:

index.php

1
2
3
4
5
define('SHOW_ERRORS', (bool) getenv("SHOW_ERRORS"));
if (SHOW_ERRORS) {
    error_reporting(E_ALL);
    ini_set('display_errors', true);
}