-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_env
98 lines (85 loc) · 2.44 KB
/
init_env
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
#!/usr/bin/env php
<?php
function getEnvironment($key, $default)
{
return getenv($key) ? getenv($key) : $default;
}
function getAppDebug()
{
if (getEnvironment('APP_ENV', 'development') === 'development') {
return 'true';
}
return 'false';
}
function getAppKey()
{
$path = (__DIR__) . '/.env';
if (!is_file($path)) {
return '';
}
$content = file_get_contents($path);
$appKey = '';
foreach (explode("\n", $content) as $item) {
if (strpos($item, 'APP_KEY=') !== false) {
$appKey = str_replace('APP_KEY=', '', $item);
break;
}
}
return $appKey;
}
$content = [
'APP_NAME=' . getEnvironment('PROJECT_ALIAS', 'panel'),
'APP_ENV=' . getEnvironment('APP_ENV', 'development'),
'APP_KEY=' . getAppKey(),
'APP_DEBUG=' . getAppDebug(),
'APP_URL=http://localhost',
'',
'LOG_CHANNEL=stack',
'',
'DB_CONNECTION=mysql',
'DB_HOST=' . getEnvironment('MYSQL_HOST', '127.0.0.1'),
'DB_PORT=' . getEnvironment('MYSQL_PORT', '3306'),
'DB_DATABASE=' . getEnvironment('MYSQL_DATABASE', 'example'),
'DB_USERNAME=' . getEnvironment('MYSQL_USER', 'root'),
'DB_PASSWORD=' . getEnvironment('MYSQL_PASSWORD', ''),
'',
'PANEL_ALIAS=' . getEnvironment('PANEL_ALIAS', 'panel'),
'IJSON_HOST=' . getEnvironment('IJSON_HOST', ''),
'',
'CONTROL_PANEL_DISABLE=' . getEnvironment('CONTROL_PANEL_DISABLE', 'no'),
'AUTHORIZATION_DISABLE=' . getEnvironment('AUTHORIZATION_DISABLE', 'yes'),
'DATABASE_SEEDER_DISABLE=' . getEnvironment('DATABASE_SEEDER_DISABLE', 'no'),
'',
'BROADCAST_DRIVER=log',
'CACHE_DRIVER=file',
'QUEUE_CONNECTION=sync',
'SESSION_DRIVER=file',
'SESSION_LIFETIME=120',
'',
'REDIS_HOST=127.0.0.1',
'REDIS_PASSWORD=null',
'REDIS_PORT=6379',
'',
'MAIL_MAILER=smtp',
'MAIL_HOST=smtp.mailtrap.io',
'MAIL_PORT=2525',
'MAIL_USERNAME=null',
'MAIL_PASSWORD=null',
'MAIL_ENCRYPTION=null',
'MAIL_FROM_ADDRESS=null',
'MAIL_FROM_NAME="${APP_NAME}"',
'',
'AWS_ACCESS_KEY_ID=',
'AWS_SECRET_ACCESS_KEY=',
'AWS_DEFAULT_REGION=us-east-1',
'AWS_BUCKET=',
'',
'PUSHER_APP_ID=',
'PUSHER_APP_KEY=',
'PUSHER_APP_SECRET=',
'PUSHER_APP_CLUSTER=mt1',
'',
'MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"',
'MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"'
];
file_put_contents((__DIR__) . '/.env', implode("\n", $content));