This repository has been archived by the owner on Jan 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.php
141 lines (132 loc) · 5.28 KB
/
install.php
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* Application initialization console command entry script.
*
* In order to initialize application run the following console command:
* php install.php init
*
* To get help type:
* php install.php help init
*
* In order to run this script in automatic mode use the following:
* php install.php init --interactive=0 --config=/path/to/my/config/install.php
*/
$basePath = __DIR__;
$hostName = @exec('hostname');
if (empty($hostName)) {
$hostName = 'unknownhost.com';
}
$userName = @exec('whoami');
if (empty($userName)) {
$userName = 'root';
}
$isDebugServer = (stripos($hostName, 'debug') !== false || stripos($hostName, 'devel') !== false || stripos($hostName, 'devplatform') !== false);
// Adjust the application configuration if necessary:
$config = [
'id' => 'project-installer',
'basePath' => $basePath,
'bootstrap' => ['log'],
'name' => 'MyProject',
'enableCoreCommands' => false,
'defaultRoute' => 'init',
'controllerMap' => [
'init' => [
'class' => yii2tech\install\InitController::class,
'localDirectories' => [
'@app/web/assets',
'@app/web/sitemap',
'@runtime',
],
'tmpDirectories' => [
'@app/web/assets',
'@app/web/sitemap',
'@runtime/URI',
'@runtime/HTML',
'@runtime/debug',
'@runtime/gii',
],
'localFiles' => [
'@app/web/.htaccess',
'@app/webstub/.htaccess',
'@app/config/local.php',
'@app/config/self-update.php',
'@app/tests/codeception/backend/acceptance.suite.yml',
'@app/tests/codeception/frontend/acceptance.suite.yml',
],
'localFilePlaceholders' => [
'yiiDebug' => [
'hint' => 'Debug mode, should be 1 at development server and 0 - at production',
'default' => $isDebugServer ? '1' : '0',
'type' => 'boolean',
],
'yiiEnv' => [
'hint' => 'Application environment, The value could be "prod" (production), "dev" (development), "test", "staging", etc.',
'default' => $isDebugServer ? 'dev' : 'prod',
'type' => 'string',
],
// Database:
'dbHost' => [
'hint' => 'Database hostname: ip address or domain name, usually: "localhost"',
'default' => $isDebugServer ? 'mysql.dev.server.com' : 'localhost',
],
'dbName' => [
'hint' => 'Database name (make sure such database exists)',
'default' => 'myproject',
],
'dbUser' => [
'hint' => 'Database access user name',
'default' => $userName,
],
'dbPassword' => [
'hint' => 'Database access password',
//'default' => '???',
],
// URL fallback for console application :
'hostInfo' => [
'hint' => 'URL for the web server root (domain name with leading protocol)',
'default' => $isDebugServer ? "http://debug.server.com/{$userName}/myproject/" : 'http://' . $hostName,
'rules' => [
['url']
],
],
'baseUrl' => [
'hint' => 'Part of the URL, which leads for the project web root. At the live server it is usually empty, in development - "/developer/myproject"',
'default' => '',
],
],
'commands' => [
'php ' . escapeshellarg($basePath . '/yii') . ' migrate/up --interactive=0',
'php ' . escapeshellarg($basePath . '/yii') . ' sitemap/generate --interactive=0',
],
// Cron jobs :
/*'cronTab' => [
'mergeFilter' => function ($line) use ($basePath) {
if (stripos($line, 'php ' . escapeshellarg($basePath . '/yii') . ' ') !== false && stripos($line, ' self-update') === false) {
return true;
}
return false;
},
'jobs' => [
[
'min' => '0',
'hour' => '0',
'command' => "php {$basePath}/yii some-cron",
],
],
],*/
],
],
];
// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
$autoloadFile = $basePath . '/vendor/autoload.php';
if (!file_exists($autoloadFile)) {
$composerBin = file_exists($basePath . '/composer.phar') ? $basePath . '/composer.phar' : 'composer';
passthru('(cd ' . escapeshellarg($basePath) . "; {$composerBin} install)");
}
require($autoloadFile);
require($basePath . '/vendor/yiisoft/yii2/Yii.php');
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);