I've come across such a scenario, to duplicate a project when a new user sign up, some of the settings in config.php have to change accordingly.

Example file content:

config.php

1
2
3
4
5
6
7
8
9
10
11
12
<?php
define('DATABASE_NAME', 'my_db');
define('DATABASE_USER', 'my_db_user');
define('DATABASE_PASSWORD', 'my_db_pass');
define('CLIENT_NAME', '');
define('CLIENT_KEY','');
define...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
$client = ....;
$client_key = ...;
$config_file = $client.'/config.php';
$newcontent = '';
// open the file
$fp = fopen($config_file, 'r');
if ($fp) {
// read the content line by line
while (($line = fgets($fp)) !== false) {
if (preg_match('/CLIENT_NAME/', $line)) {
// e.g. want to replace the client name
$newcontent .= 'define(\'CLIENT_NAME\', \'' . $client . '\');'.PHP_EOL;
} else if (preg_match('/CLIENT_KEY/', $line)) {
// e.g. want to replace client secret key
$newcontent .= 'define(\'CLIENT_KEY\', \'' . $client_key . '\');'.PHP_EOL;
} else { // otherwise just append the line
$newcontent .= $line;
}
}
}
fclose($fp);
// replace the file with new content
file_put_contents($config_file, $newcontent);