Initial Commit with ENVs, directory structures, cursor rules, etc
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/env.php';
|
||||
|
||||
// Load environment variables
|
||||
Env::load();
|
||||
|
||||
// Paths
|
||||
define('ROOT_PATH', dirname(__DIR__));
|
||||
define('DATA_PATH', ROOT_PATH . '/data');
|
||||
define('EXPORT_PATH', ROOT_PATH . '/exports');
|
||||
|
||||
// Google API Configuration
|
||||
define('GOOGLE_CLIENT_ID', Env::get('GOOGLE_CLIENT_ID'));
|
||||
define('GOOGLE_CLIENT_SECRET', Env::get('GOOGLE_CLIENT_SECRET'));
|
||||
define('GOOGLE_REDIRECT_URI', Env::get('GOOGLE_REDIRECT_URI'));
|
||||
define('GOOGLE_CALENDAR_ID', Env::get('GOOGLE_CALENDAR_ID'));
|
||||
define('GOOGLE_CALENDAR_EMBED_CODE', Env::get('GOOGLE_CALENDAR_EMBED_CODE'));
|
||||
define('GOOGLE_DRIVE_FOLDER_ID', Env::get('GOOGLE_DRIVE_FOLDER_ID'));
|
||||
|
||||
// Application Settings
|
||||
define('APP_ENV', Env::get('APP_ENV', 'production'));
|
||||
define('APP_DEBUG', Env::get('APP_DEBUG', 'false') === 'true');
|
||||
define('APP_URL', Env::get('APP_URL', 'http://localhost/family-hub'));
|
||||
|
||||
// Export settings
|
||||
define('EXPORT_DESTINATION', EXPORT_PATH);
|
||||
define('EXPORT_FREQUENCY', Env::get('EXPORT_FREQUENCY', 'daily'));
|
||||
define('EXPORT_RETENTION_DAYS', (int)Env::get('EXPORT_RETENTION_DAYS', 30));
|
||||
|
||||
// Tab configuration
|
||||
$TABS = [
|
||||
'chores' => ['title' => 'Chores', 'icon' => 'tasks'],
|
||||
'groceries' => ['title' => 'Grocery List', 'icon' => 'shopping-cart'],
|
||||
'meals' => ['title' => 'Meal Plan', 'icon' => 'utensils']
|
||||
];
|
||||
|
||||
// Load local configuration if exists
|
||||
if (file_exists(__DIR__ . '/local.php')) {
|
||||
include __DIR__ . '/local.php';
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
class Env {
|
||||
private static $variables = [];
|
||||
|
||||
public static function load() {
|
||||
$envFile = dirname(__DIR__) . '/.env';
|
||||
|
||||
if (!file_exists($envFile)) {
|
||||
throw new Exception('.env file not found. Please create one based on .env.example');
|
||||
}
|
||||
|
||||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
// Skip comments
|
||||
if (strpos(trim($line), '#') === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list($name, $value) = explode('=', $line, 2);
|
||||
$name = trim($name);
|
||||
$value = trim($value);
|
||||
|
||||
// Remove quotes if present
|
||||
if (strpos($value, '"') === 0 || strpos($value, "'") === 0) {
|
||||
$value = substr($value, 1, -1);
|
||||
}
|
||||
|
||||
self::$variables[$name] = $value;
|
||||
putenv("$name=$value");
|
||||
}
|
||||
}
|
||||
|
||||
public static function get($key, $default = null) {
|
||||
return self::$variables[$key] ?? $default;
|
||||
}
|
||||
|
||||
public static function all() {
|
||||
return self::$variables;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user