Skip to content

Instantly share code, notes, and snippets.

@theking2
Created January 27, 2024 16:14
Show Gist options
  • Save theking2/d66eb261533dc608c0f2e7a51f25d349 to your computer and use it in GitHub Desktop.
Save theking2/d66eb261533dc608c0f2e7a51f25d349 to your computer and use it in GitHub Desktop.
php settings
<?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