Created
January 27, 2024 16:14
-
-
Save theking2/d66eb261533dc608c0f2e7a51f25d349 to your computer and use it in GitHub Desktop.
php settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( !defined( 'ROOT' ) ) { | |
define( 'ROOT', $_SERVER[ 'DOCUMENT_ROOT'] . '/' ); | |
} | |
if(!defined( 'SETTINGS_FILE' ) ) { | |
define('SETTINGS_FILE', ROOT . 'settings.ini' ); | |
} | |
if( !defined( 'SETTINGS') ) { | |
$settings = parse_ini_file( SETTINGS_FILE, true ); | |
if( false === $settings ) { | |
exit( "error reading settings" ); | |
} | |
$settings['db']['dsn'] = sprintf( 'mysql:host=%s;dbname=%s;charset=utf8mb4', | |
$settings['db']['server'], | |
$settings['db']['database'] | |
); | |
$settings['development'] = strpos($_SERVER['SERVER_NAME'], 'localhost') !== false; | |
define( 'SETTINGS', $settings ); | |
unset( $settings ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment