Configuration


Configuration

The data for dframe should be in the app/bootstrap.php file. It contains libraries and variables for the whole application, sent through the variable $this->baseClass. In the web/config.php file, CONST values are added and stored.

use Dframe\Database\Database;
use \PDO;

try {
   $dbConfig = [
       'host' => DB_HOST,
       'dbname' => DB_DATABASE,
       'username' => DB_USER,
       'password' => DB_PASS
   ];
   
   // Debug Config 
   $config = [
       'logDir' => APP_DIR . 'View/logs/',
       'attributes' => [
           PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", 
           //PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT,  // Set pdo error mode silent
           PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // If you want to Show Class exceptions on Screen, Uncomment below code 
           PDO::ATTR_EMULATE_PREPARES => true, // Use this setting to force PDO to either always emulate prepared statements (if TRUE), or to try to use native prepared statements (if FALSE). 
           PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC // Set default pdo fetch mode as fetch assoc
        ]
   ];
   
   /**
    * Method #1 
    */  
   $dsn = [
       'host' => DB_HOST,
       'dbname' => DB_DATABASE,
       'dbtype' => 'mysql'
   ];
   $db = new Database($dsn, DB_USER, DB_PASS, $config);
   
   /**
    * Method #2
    */  
   //$db = new Database('mysql:host='.DB_HOST.';dbname=' . DB_DATABASE . ';port=3306', DB_USER, DB_PASS, $config);
   
   $db->setErrorLog(false); // Debug
 
}catch(\Exception $e) {
    echo 'The connect can not create: ' . $e->getMessage(); 
    exit();
}
Edit page (Configuration)