43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
// Carica le variabili dal .env (stessa fonte della webapp)
|
|
$root = __DIR__;
|
|
if (file_exists($root . '/vendor/autoload.php')) {
|
|
require_once $root . '/vendor/autoload.php';
|
|
}
|
|
|
|
if (class_exists(\Dotenv\Dotenv::class)) {
|
|
$dotenv = \Dotenv\Dotenv::createImmutable($root);
|
|
$dotenv->safeLoad(); // safeLoad: non lancia errori se manca il .env
|
|
}
|
|
|
|
// Helper: legge da $_ENV, getenv() o usa un default
|
|
$env = function (string $key, $default = null) {
|
|
$v = $_ENV[$key] ?? getenv($key);
|
|
if ($v === false || $v === null) {
|
|
return $default;
|
|
}
|
|
// toglie eventuali virgolette attorno al valore
|
|
return trim($v, "\"'");
|
|
};
|
|
|
|
return [
|
|
'paths' => [
|
|
'migrations' => __DIR__ . '/db/migrations',
|
|
'seeds' => __DIR__ . '/db/seeds',
|
|
],
|
|
'environments' => [
|
|
'default_migration_table' => 'phinxlog',
|
|
'default_environment' => 'development',
|
|
'development' => [
|
|
'adapter' => $env('DB_CONNECTION', 'mysql'),
|
|
'host' => $env('DB_HOST', '127.0.0.1'),
|
|
'name' => $env('DB_DATABASE', 'casadocdb'),
|
|
'user' => $env('DB_USERNAME', 'root'),
|
|
'pass' => $env('DB_PASSWORD', ''),
|
|
'port' => (int) $env('DB_PORT', 3306),
|
|
'charset' => 'utf8mb4',
|
|
],
|
|
],
|
|
'version_order' => 'creation',
|
|
];
|