Add a proper config system
This commit is contained in:
parent
6de2ac40df
commit
29b919fd15
2
.gitignore
vendored
2
.gitignore
vendored
@ -49,4 +49,4 @@ Thumbs.db
|
|||||||
*.db
|
*.db
|
||||||
*.sqlite
|
*.sqlite
|
||||||
*.zip
|
*.zip
|
||||||
|
/src/config.php
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
"input": "src/api",
|
"input": "src/api",
|
||||||
"output": "/api"
|
"output": "/api"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"glob": "config*.php",
|
||||||
|
"input": "src",
|
||||||
|
"output": "/"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"glob": "*.json",
|
"glob": "*.json",
|
||||||
"input": "src/json",
|
"input": "src/json",
|
||||||
|
@ -11,7 +11,13 @@ use RedBeanPHP\R;
|
|||||||
|
|
||||||
require './vendor/autoload.php';
|
require './vendor/autoload.php';
|
||||||
|
|
||||||
R::setup('sqlite:taskboard.sqlite');
|
$CONFIG = require('../config.default.php');
|
||||||
|
if (file_exists('../config.php')) {
|
||||||
|
$CONFIG = array_merge($CONFIG, require('../config.php'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
R::setup($CONFIG['database'], $CONFIG['database_user'], $CONFIG['database_password']);
|
||||||
|
|
||||||
$container = new DI\Container();
|
$container = new DI\Container();
|
||||||
AppFactory::setContainer($container);
|
AppFactory::setContainer($container);
|
||||||
|
23
src/config.default.php
Normal file
23
src/config.default.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
// Do not edit config.default.php as this may hinder your upgrade to a future version.
|
||||||
|
// Make a copy of it called config.php!
|
||||||
|
|
||||||
|
return array(
|
||||||
|
/**
|
||||||
|
* Database configuration settings.
|
||||||
|
*
|
||||||
|
* SQLite does not use or need a user or password.
|
||||||
|
*
|
||||||
|
* For SQLite, use sqlite:path_to_db.sqlite (the path is relative to the api/ directory).
|
||||||
|
*
|
||||||
|
* For Postgres, use e.g. pgsql:host=localhost;dbname=taskboard for a TCP connection,
|
||||||
|
* or e.g. pgsql:dbname=taskboard for a UNIX socket connection
|
||||||
|
*
|
||||||
|
* See https://redbeanphp.com/index.php?p=/connection for more options.
|
||||||
|
*/
|
||||||
|
'database' => 'sqlite:taskboard.sqlite',
|
||||||
|
'database_user' => '',
|
||||||
|
'database_password' => '',
|
||||||
|
|
||||||
|
|
||||||
|
);
|
Reference in New Issue
Block a user