I want to make settings to install my application like wordpress.
I tried to make a new file like wordpress.
but I have difficulty when making it.
first option :
PHP Code:
if ( ! file_exists(APPPATH.'config/my_database.php')) {
$data = array(
'$config["database_name"] = "my-name"',
);
//I'm having trouble creating a my_database file with values like this:
//$config[username] = 'my-name';
//$config[userpass] = 'my-pass';
//etc.
if ( ! write_file(APPPATH.'config/my_database.php', $data)) {
echo 'Unable to write the file';
} else {
echo 'File written!';
}
}
second option :
PHP Code:
if ( ! file_exists(APPPATH.'config/database.php')) {
if (copy(APPPATH.'config/database_example.php', APPPATH.'config/database.php')) {
// I'm having a problem here, before copying data $db['defult'] = array for database.php
// changed according to the configuration form later.
// I tried using the file_put_contents() function but failed.
echo 'Copy Success';
} else {
echo 'Copy Failed!';
}
}
or if there is another way let me know
Please help and thank you