-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
46 lines (35 loc) · 1.2 KB
/
install.php
File metadata and controls
46 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Replaces the default werx\Skeleton namespace with your own namespace.
*/
if ($argc < 2) {
print 'Usage: php install.php "Your\App\Namespace"' . PHP_EOL;
exit;
} else {
$namespace = $argv[1];
}
$slash = "\\";
$double_slash = "\\\\";
$namespace_escaped = str_replace($slash, $double_slash, $namespace);
// Update composer.json (for autoloading)
file_put_contents('./composer.json', str_replace('werx\\\\Skeleton', $namespace_escaped, file_get_contents('./composer.json')));
$paths = ['src','web'];
// Update in all the class files
foreach ($paths as $p) {
$files = rglob($p . '/*.php');
foreach ($files as $f) {
$content = file_get_contents($f);
$content = str_replace('werx\Skeleton', $namespace, $content);
$content = str_replace('werx\\Skeleton', $namespace_escaped, $content);
file_put_contents($f, $content);
}
}
// Recreate autoload files.
print `composer dump-autoload`;
function rglob($pattern, $flags = 0) {
$files = preg_grep('/vendor/', glob($pattern, $flags), PREG_GREP_INVERT);
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
$files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
}
return $files;
}