mirror of
https://codeberg.org/vlw/scaffold.git
synced 2026-04-13 04:49:38 +02:00
Compare commits
3 commits
723b048c8f
...
f4b8f8673e
| Author | SHA1 | Date | |
|---|---|---|---|
| f4b8f8673e | |||
| 1536079fe3 | |||
| c501201f11 |
3 changed files with 33 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
# Scaffold
|
# Scaffold
|
||||||
This composer package contains my project boilerplate code for working with [Vegvisir](https://vegvisir.vlw.se) and [Reflect](https://reflect.vlw.se) projects. It contains my most commonly used classes and functions which I use to make development of new project in these frameworks easier.
|
This composer package (primarily) contains my project boilerplate code for working with [Vegvisir](https://vegvisir.vlw.se) and [Reflect](https://reflect.vlw.se) projects. It contains my most commonly used classes and functions which I use to make development of new project in these frameworks easier.
|
||||||
|
|
||||||
Refer to the documentation in each source file for more information about its function.
|
Refer to the documentation in each source file for more information about its function.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "vlw/scaffold",
|
"name": "vlw/scaffold",
|
||||||
"description": "Project scaffolding for Reflect and Vegvisir projects",
|
"description": "Project scaffolding (primarily) for Reflect and Vegvisir projects",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,37 @@
|
||||||
public const DATE_FORMAT = "Y-m-d";
|
public const DATE_FORMAT = "Y-m-d";
|
||||||
public const DATETIME_FORMAT = "Y-m-d H:i:s";
|
public const DATETIME_FORMAT = "Y-m-d H:i:s";
|
||||||
|
|
||||||
|
private const DEFAULT_HOSTNAME = "localhost";
|
||||||
|
private const DEFAULT_USERNAME = "www-data";
|
||||||
|
private const DEFAULT_PASSWORD = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Database instance from credentials
|
||||||
|
*
|
||||||
|
* @param string $host
|
||||||
|
* @param string $username
|
||||||
|
* @param string $password
|
||||||
|
* @param string $database
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function set_credentials(
|
||||||
|
?string $host = self::DEFAULT_HOSTNAME,
|
||||||
|
?string $username = self::DEFAULT_USERNAME,
|
||||||
|
?string $password = self::DEFAULT_PASSWORD,
|
||||||
|
string $database
|
||||||
|
) {
|
||||||
|
// Create key if it does not exist
|
||||||
|
if (!$_ENV["mariadb"]) {
|
||||||
|
$_ENV["mariadb"] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set environment variables from credentials
|
||||||
|
$_ENV["mariadb"]["host"] = $host;
|
||||||
|
$_ENV["mariadb"]["user"] = $username;
|
||||||
|
$_ENV["mariadb"]["pass"] = $password;
|
||||||
|
$_ENV["mariadb"]["db"] = $database;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap a new vlw/MySQL instance with credentials from project .env.ini
|
* Wrap a new vlw/MySQL instance with credentials from project .env.ini
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue