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 4
/
Copy pathinstall.php
126 lines (117 loc) · 4.59 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
<?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' => 'my-project-installer',
'basePath' => $basePath,
'bootstrap' => ['log'],
'name' => 'MyProject',
'enableCoreCommands' => false,
'controllerMap' => [
'init' => [
'class' => 'yii2tech\install\InitController',
'localDirectories' => [
'@app/web/assets',
'@runtime',
],
'tmpDirectories' => [
'@app/web/assets',
'@runtime/URI',
'@runtime/HTML',
'@runtime/debug',
'@runtime/gii',
],
'localFiles' => [
'@app/config/local.php',
],
'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',
],
// Database:
'dbHost' => [
'hint' => 'Database hostname: ip address or domain name, usually: "localhost"',
'default' => $isDebugServer ? 'debug.sql-server.com' : 'localhost',
],
'dbName' => [
'hint' => 'Database name (make sure such database exists)',
'default' => $isDebugServer ? $userName . '_myproject' : '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://myproject.' . $userName . '.' . $hostName : '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 {$basePath}/yii migrate/up --interactive=0"
],
// Cron jobs :
/*'cronTab' => [
'mergeFilter' => "php {$basePath}/yii ",
'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} global require 'fxp/composer-asset-plugin:^1.3.1'; {$composerBin} install)");
}
require($autoloadFile);
require($basePath . '/vendor/yiisoft/yii2/Yii.php');
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);