eccube_install.php ➔ composerSetup()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 13
nc 3
nop 0
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 4.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
if (php_sapi_name() !== 'cli') {
4
    exit(1);
5
}
6
7
set_time_limit(0);
8
ini_set('display_errors', 1);
9
10
define('COMPOSER_FILE', 'composer.phar');
11
define('COMPOSER_SETUP_FILE', 'composer-setup.php');
12
13
setUseAnsi($argv);
14
15
$argv = is_array($argv) ? $argv : array();
16
17
$argv[1] = isset($argv[1]) ? $argv[1] : null;
18
$argv[2] = isset($argv[2]) ? $argv[2] : null;
19
20
if (in_array('--help', $argv) || empty($argv[1])) {
21
    displayHelp($argv);
22
    exit(0);
23
}
24
25
if (in_array('-v', $argv) || in_array('--version', $argv)) {
26
    require __DIR__.'/src/Eccube/Common/Constant.php';
27
    echo 'EC-CUBE '.Eccube\Common\Constant::VERSION.PHP_EOL;
28
    exit(0);
29
}
30
31
out('EC-CUBE3 installer use database driver of ', null, false);
32
33
$database_driver = 'pdo_sqlite';
34
switch($argv[1]) {
35
    case 'mysql':
36
        $database_driver = 'pdo_mysql';
37
        break;
38
    case 'pgsql':
39
        $database_driver = 'pdo_pgsql';
40
        break;
41
    default:
42
    case 'sqlite':
43
    case 'sqlite3':
44
    case 'sqlite3-in-memory':
45
        $database_driver = 'pdo_sqlite';
46
}
47
out($database_driver);
48
49
initializeDefaultVariables($database_driver);
50
51
if (in_array('-V', $argv) || in_array('--verbose', $argv)) {
52
    displayEnvironmentVariables();
53
}
54
55
$database = getDatabaseConfig($database_driver);
56
$connectionParams = $database['database'];
57
58
if ($argv[2] != 'none') {
59
    composerSetup();
60
    composerInstall();
61
}
62
63
require __DIR__.'/autoload.php';
64
65
out('update permissions...');
66
updatePermissions($argv);
67
68
createConfigFiles($database_driver);
69
70
if (!in_array('--skip-createdb', $argv)) {
71
    createDatabase($connectionParams);
72
}
73
74
if (!in_array('--skip-initdb', $argv)) {
75
    $app = createApplication();
76
    initializeDatabase($app);
77
}
78
79
out('EC-CUBE3 install finished successfully!', 'success');
80
$root_urlpath = getenv('ROOT_URLPATH');
81
if (PHP_VERSION_ID >= 50400 && empty($root_urlpath)) {
82
    out('PHP built-in web server to run applications, `php -S localhost:8080 -t html`', 'info');
83
    out('Open your browser and access the http://localhost:8080/', 'info');
84
}
85
exit(0);
86
87
function displayHelp($argv)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "displayHelp" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
88
{
89
    echo <<<EOF
90
EC-CUBE3 Installer
91
------------------
92
Usage:
93
${argv[0]} [mysql|pgsql|sqlite3] [none] [options]
94
95
Arguments[1]:
96
Specify database types
97
98
Arguments[2]:
99
Specifying the "none" to skip the installation of Composer
100
101
Options:
102
-v, --version        print ec-cube version
103
-V, --verbose        enable verbose output
104
--skip-createdb      skip to create database
105
--skip-initdb        skip to initialize database
106
--help               this help
107
--ansi               force ANSI color output
108
--no-ansi            disable ANSI color output
109
110
Environment variables:
111
112
EOF;
113
    foreach (getExampleVariables() as $name => $value) {
114
        echo $name.'='.$value.PHP_EOL;
115
    }
116
}
117
118
function initializeDefaultVariables($database_driver)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "initializeDefaultVariables" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
119
{
120
    $database_url = getenv('DATABASE_URL');
121
    if ($database_url) {
122
        $url = parse_url($database_url);
123
        putenv('DBSERVER='.$url['host']);
124
        putenv('DBNAME='.substr($url['path'], 1));
125
        putenv('DBUSER='.$url['user']);
126
        putenv('DBPORT='.$url['port']);
127
        putenv('DBPASS='.$url['pass']);
128
    }
129
    switch ($database_driver) {
130
        case 'pdo_pgsql':
131
            putenv('ROOTUSER='.(getenv('ROOTUSER') ? getenv('ROOTUSER') : (getenv('DBUSER') ? getenv('DBUSER') : 'postgres')));
132
            putenv('ROOTPASS='.(getenv('ROOTPASS') ? getenv('ROOTPASS') : (getenv('DBPASS') ? getenv('DBPASS') : 'password')));
133
            putenv('DBSERVER='.(getenv('DBSERVER') ? getenv('DBSERVER') : 'localhost'));
134
            putenv('DBNAME='.(getenv('DBNAME') ? getenv('DBNAME') : 'cube3_dev'));
135
            putenv('DBUSER='.(getenv('DBUSER') ? getenv('DBUSER') : 'cube3_dev_user'));
136
            putenv('DBPORT='.(getenv('DBPORT') ? getenv('DBPORT') : '5432'));
137
            putenv('DBPASS='.(getenv('DBPASS') ? getenv('DBPASS') : 'password'));
138
            break;
139
        case 'pdo_mysql':
140
            putenv('ROOTUSER='.(getenv('ROOTUSER') ? getenv('ROOTUSER') : (getenv('DBUSER') ? getenv('DBUSER') : 'root')));
141
            putenv('DBSERVER='.(getenv('DBSERVER') ? getenv('DBSERVER') : 'localhost'));
142
            putenv('DBNAME='.(getenv('DBNAME') ? getenv('DBNAME') : 'cube3_dev'));
143
            putenv('DBUSER='.(getenv('DBUSER') ? getenv('DBUSER') : 'cube3_dev_user'));
144
            putenv('DBPORT='.(getenv('DBPORT') ? getenv('DBPORT') : '3306'));
145
            putenv('DBPASS='.(getenv('DBPASS') ? getenv('DBPASS') : 'password'));
146
            if (getenv('TRAVIS')) {
147
                putenv('DBPASS=');
148
                putenv('ROOTPASS=');
149
            } else {
150
                putenv('DBPASS='.(getenv('DBPASS') ? getenv('DBPASS') : 'password'));
151
                putenv('ROOTPASS='.(getenv('ROOTPASS') ? getenv('ROOTPASS') : (getenv('DBPASS') ? getenv('DBPASS') : 'password')));
152
            }
153
            break;
154
        default:
155
        case 'pdo_sqlite':
156
            break;
157
    }
158
    putenv('SHOP_NAME='.(getenv('SHOP_NAME') ? getenv('SHOP_NAME') : 'EC-CUBE SHOP'));
159
    putenv('ADMIN_MAIL='.(getenv('ADMIN_MAIL') ? getenv('ADMIN_MAIL') : '[email protected]'));
160
    putenv('ADMIN_USER='.(getenv('ADMIN_USER') ? getenv('ADMIN_USER') : 'admin'));
161
    putenv('ADMIN_PASS='.(getenv('ADMIN_PASS') ? getenv('ADMIN_PASS') : 'password'));
162
    putenv('MAIL_BACKEND='.(getenv('MAIL_BACKEND') ? getenv('MAIL_BACKEND') : 'smtp'));
163
    putenv('MAIL_HOST='.(getenv('MAIL_HOST') ? getenv('MAIL_HOST') : 'localhost'));
164
    putenv('MAIL_PORT='.(getenv('MAIL_PORT') ? getenv('MAIL_PORT') : 25));
165
    putenv('MAIL_USER='.(getenv('MAIL_USER') ? getenv('MAIL_USER') : null));
166
    putenv('MAIL_PASS='.(getenv('MAIL_PASS') ? getenv('MAIL_PASS') : null));
167
    putenv('ADMIN_ROUTE='.(getenv('ADMIN_ROUTE') ? getenv('ADMIN_ROUTE') : 'admin'));
168
    putenv('ROOT_URLPATH='.(getenv('ROOT_URLPATH') ? getenv('ROOT_URLPATH') : null));
169
    putenv('AUTH_MAGIC='.(getenv('AUTH_MAGIC') ? getenv('AUTH_MAGIC') :
170
                          substr(str_replace(array('/', '+', '='), '', base64_encode(openssl_random_pseudo_bytes(32 * 2))), 0, 32)));
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 4 spaces, but found 26.
Loading history...
171
}
172
173
function getExampleVariables()
0 ignored issues
show
Coding Style introduced by
Consider putting global function "getExampleVariables" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
174
{
175
    return array(
0 ignored issues
show
introduced by
Add a comma after each item in a multi-line array
Loading history...
176
        'ADMIN_USER' => 'admin',
177
        'ADMIN_MAIL' => '[email protected]',
178
        'SHOP_NAME' => 'EC-CUBE SHOP',
179
        'ADMIN_ROUTE' => 'admin',
180
        'ROOT_URLPATH' => '<ec-cube install path>',
181
        'DBSERVER' => '127.0.0.1',
182
        'DBNAME' => 'cube3_dev',
183
        'DBUSER' => 'cube3_dev_user',
184
        'DBPASS' => 'password',
185
        'DBPORT' => '<database port>',
186
        'ROOTUSER' => 'root|postgres',
187
        'ROOTPASS' => 'password',
188
        'MAIL_BACKEND' => 'smtp',
189
        'MAIL_HOST' => 'localhost',
190
        'MAIL_PORT' => '25',
191
        'MAIL_USER' => '<SMTP AUTH user>',
192
        'MAIL_PASS' => '<SMTP AUTH password>',
193
        'AUTH_MAGIC' => '<auth_magic>'
194
    );
195
}
196
197
198
function displayEnvironmentVariables()
0 ignored issues
show
Coding Style introduced by
Consider putting global function "displayEnvironmentVariables" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
199
{
200
    echo 'Environment variables:'.PHP_EOL;
201
    foreach (array_keys(getExampleVariables()) as $name) {
202
        echo $name.'='.getenv($name).PHP_EOL;
203
    }
204
}
205
206
function composerSetup()
0 ignored issues
show
Coding Style introduced by
Consider putting global function "composerSetup" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
207
{
208
    if (!file_exists(__DIR__.'/'.COMPOSER_FILE)) {
209
        if (!file_exists(__DIR__.'/'.COMPOSER_SETUP_FILE)) {
210
            copy('https://getcomposer.org/installer', COMPOSER_SETUP_FILE);
211
        }
212
213
        $sha = hash_file('SHA384', COMPOSER_SETUP_FILE).PHP_EOL;
214
        out(COMPOSER_SETUP_FILE.': '.$sha);
215
216
        $command = 'php '.COMPOSER_SETUP_FILE;
217
        out("execute: $command", 'info');
218
        passthru($command);
219
        unlink(COMPOSER_SETUP_FILE);
220
    } else {
221
        $command = 'php '.COMPOSER_FILE.' self-update';
222
        passthru($command);
223
    }
224
}
225
226
function composerInstall()
0 ignored issues
show
Coding Style introduced by
Consider putting global function "composerInstall" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
227
{
228
    $command = 'php '.COMPOSER_FILE.' install --dev --no-interaction';
229
    passthru($command);
230
}
231
232
function createDatabase(array $connectionParams)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "createDatabase" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
233
{
234
    $dbname = $connectionParams['dbname'];
235
    switch ($connectionParams['driver']) {
236 View Code Duplication
        case 'pdo_pgsql':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
237
            $connectionParams['dbname'] = 'postgres';
238
            $connectionParams['user'] = getenv('ROOTUSER');
239
            $connectionParams['password'] = getenv('ROOTPASS');
240
            break;
241 View Code Duplication
        case 'pdo_mysql':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
242
            $connectionParams['dbname'] = 'mysql';
243
            $connectionParams['user'] = getenv('ROOTUSER');
244
            $connectionParams['password'] = getenv('ROOTPASS');
245
            break;
246
        default:
247
        case 'pdo_sqlite':
248
            $connectionParams['dbname'] = '';
249
            if (file_exists($dbname)) {
250
                out('remove database to '.$dbname, 'info');
251
                unlink($dbname);
252
            }
253
            break;
254
    }
255
256
    $config = new \Doctrine\DBAL\Configuration();
257
    $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
258
    $sm = $conn->getSchemaManager();
259
    out('Created database connection...', 'info');
260
261
    if ($connectionParams['driver'] != 'pdo_sqlite') {
262
        $databases = $sm->listDatabases();
263
        if (in_array($dbname, $databases)) {
264
            out('database exists '.$dbname, 'info');
265
            out('drop database to '.$dbname, 'info');
266
            $sm->dropDatabase($dbname);
267
        }
268
    }
269
    out('create database to '.$dbname, 'info');
270
    $sm->createDatabase($dbname);
271
}
272
273
/**
274
 * @return \Eccube\Application
275
 */
276
function createApplication()
0 ignored issues
show
Coding Style introduced by
Consider putting global function "createApplication" in a static class
Loading history...
277
{
278
    $app = \Eccube\Application::getInstance();
279
    $app['debug'] = true;
280
    $app->initDoctrine();
281
    $app->initSecurity();
282
    $app->register(new \Silex\Provider\FormServiceProvider());
283
    $app->register(new \Eccube\ServiceProvider\EccubeServiceProvider());
284
    $app->boot();
285
    return $app;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
286
}
287
288
function initializeDatabase(\Eccube\Application $app)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "initializeDatabase" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
289
{
290
    // Get an instance of your entity manager
291
    $entityManager = $app['orm.em'];
292
293
    $pdo = $entityManager->getConnection()->getWrappedConnection();
294
295
    // Clear Doctrine to be safe
296
    $entityManager->getConnection()->getConfiguration()->setSQLLogger(null);
297
    $entityManager->clear();
298
    gc_collect_cycles();
299
300
    // Schema Tool to process our entities
301
    $tool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
302
    $classes = $entityManager->getMetaDataFactory()->getAllMetaData();
303
304
    // Drop all classes and re-build them for each test case
305
    out('Dropping database schema...', 'info');
306
    $tool->dropSchema($classes);
307
    out('Creating database schema...', 'info');
308
    $tool->createSchema($classes);
309
    out('Database schema created successfully!', 'success');
310
    $config = new \Doctrine\DBAL\Migrations\Configuration\Configuration($app['db']);
311
    $config->setMigrationsNamespace('DoctrineMigrations');
312
313
    $migrationDir = __DIR__.'/src/Eccube/Resource/doctrine/migration';
314
    $config->setMigrationsDirectory($migrationDir);
315
    $config->registerMigrationsFromDirectory($migrationDir);
316
317
    $migration = new \Doctrine\DBAL\Migrations\Migration($config);
318
    $migration->migrate();
319
    out('Database migration successfully!', 'success');
320
321
    $login_id = getenv('ADMIN_USER');
322
    $login_password = getenv('ADMIN_PASS');
323
    $passwordEncoder = new \Eccube\Security\Core\Encoder\PasswordEncoder($app['config']);
324
    $salt = \Eccube\Util\Str::random(32);
325
    $encodedPassword = $passwordEncoder->encodePassword($login_password, $salt);
326
327
    out('Creating admin accounts...', 'info');
328
    $sql = "INSERT INTO dtb_member (member_id, login_id, password, salt, work, del_flg, authority, creator_id, rank, update_date, create_date,name,department) VALUES (2, :login_id, :admin_pass , :salt , '1', '0', '0', '1', '1', current_timestamp, current_timestamp,'管理者', 'EC-CUBE SHOP');";
329
    $stmt = $pdo->prepare($sql);
330
    $stmt->execute(
331
        array(
0 ignored issues
show
introduced by
Add a comma after each item in a multi-line array
Loading history...
332
            ':login_id' => $login_id,
333
            ':admin_pass' => $encodedPassword,
334
            ':salt' => $salt
335
        )
336
    );
337
    $stmt->closeCursor();
338
339
    $shop_name = getenv('SHOP_NAME');
340
    $admin_mail = getenv('ADMIN_MAIL');
341
    $sql = "INSERT INTO dtb_base_info (id, shop_name, email01, email02, email03, email04, update_date, option_product_tax_rule) VALUES (1, :shop_name, :admin_mail1, :admin_mail2, :admin_mail3, :admin_mail4, current_timestamp, 0)";
342
    $stmt = $pdo->prepare($sql);
343
    $stmt->execute(
344
        array(
345
            ':shop_name' => $shop_name,
346
            ':admin_mail1' => $admin_mail,
347
            ':admin_mail2' => $admin_mail,
348
            ':admin_mail3' => $admin_mail,
349
            ':admin_mail4' => $admin_mail,
350
        )
351
    );
352
    $stmt->closeCursor();
353
}
354
355
function updatePermissions($argv)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "updatePermissions" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
356
{
357
    $finder = \Symfony\Component\Finder\Finder::create();
358
    $finder
359
        ->in('html')->notName('.htaccess')
360
        ->in('app')->notName('console');
361
362
    $verbose = false;
363
    if (in_array('-V', $argv) || in_array('--verbose', $argv)) {
364
        $verbose = true;
365
    }
366
    foreach ($finder as $content) {
367
        $permission = $content->getPerms();
368
        // see also http://www.php.net/fileperms
369
        if (!($permission & 0x0010) || !($permission & 0x0002)) {
370
            $realPath = $content->getRealPath();
371
            if ($verbose) {
372
                out(sprintf('%s %s to ', $realPath, substr(sprintf('%o', $permission), -4)), 'info', false);
373
            }
374
            $permission = !($permission & 0x0020) ? $permission += 040 : $permission; // g+r
375
            $permission = !($permission & 0x0010) ? $permission += 020 : $permission; // g+w
376
            $permission = !($permission & 0x0004) ? $permission += 04 : $permission;  // o+r
377
            $permission = !($permission & 0x0002) ? $permission += 02 : $permission;  // o+w
378
            $result = chmod($realPath, $permission);
379
            if ($verbose) {
380
                if ($result) {
381
                    out(substr(sprintf('%o', $permission), -4), 'info');
382
                } else {
383
                    out('failure', 'error');
384
                }
385
            }
386
        }
387
    }
388
}
389
390
function createConfigFiles($database_driver)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "createConfigFiles" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
391
{
392
    $config_path = __DIR__.'/app/config/eccube';
393
    createYaml(getConfig(), $config_path.'/config.yml');
394
    createYaml(getDatabaseConfig($database_driver), $config_path.'/database.yml');
395
    createYaml(getMailConfig(), $config_path.'/mail.yml');
396
    createYaml(getPathConfig(), $config_path.'/path.yml');
397
}
398
399
function createYaml($config, $path)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "createYaml" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
400
{
401
    $content = \Symfony\Component\Yaml\Yaml::dump($config);
402
    $fs = new \Symfony\Component\Filesystem\Filesystem();
403
    $fs->dumpFile($path, $content);
404
}
405
406
function getConfig()
0 ignored issues
show
Coding Style introduced by
Consider putting global function "getConfig" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
407
{
408
    $config = array (
409
        'auth_magic' => getenv('AUTH_MAGIC'),
410
        'password_hash_algos' => 'sha256',
411
        'shop_name' => getenv('SHOP_NAME'),
412
        'force_ssl' => NULL,
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
413
        'admin_allow_host' =>
414
        array (
0 ignored issues
show
introduced by
Add a comma after each item in a multi-line array
Loading history...
415
        ),
416
        'cookie_lifetime' => 0,
417
        'locale' => 'ja',
418
        'timezone' => 'Asia/Tokyo',
419
        'eccube_install' => 1,
420
    );
421
    return $config;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
422
}
423
424
function getDatabaseConfig($database_driver)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "getDatabaseConfig" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
425
{
426
    $database = array (
0 ignored issues
show
introduced by
Add a comma after each item in a multi-line array
Loading history...
427
        'database' =>
428
        array (
429
            'driver' => $database_driver,
430
        )
431
    );
432
433
    switch ($database_driver) {
434
        case 'pdo_sqlite':
435
            $database['database']['dbname'] = $database['database']['path'] = __DIR__.'/app/config/eccube/eccube.db';
436
437
            break;
438
        case 'pdo_pgsql':
439
        case 'pdo_mysql':
440
            $database['database']['host'] = getenv('DBSERVER');
441
            $database['database']['dbname'] = getenv('DBNAME');
442
            $database['database']['user'] = getenv('DBUSER');
443
            $database['database']['port'] = getenv('DBPORT');
444
            $database['database']['password'] = getenv('DBPASS');
445
            $database['database']['port'] = getenv('DBPORT');
446
            break;
447
    }
448
    $database['database']['charset'] = 'utf8';
449
    $database['database']['defaultTableOptions'] = array('collate' => 'utf8_general_ci');
450
    return $database;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
451
}
452
453
function getMailConfig()
0 ignored issues
show
Coding Style introduced by
Consider putting global function "getMailConfig" in a static class
Loading history...
introduced by
Missing function doc comment
Loading history...
454
{
455
    $mail = array (
456
        'mail' =>
457
        array (
458
            'transport' => getenv('MAIL_BACKEND'),
459
            'host' => getenv('MAIL_HOST'),
460
            'port' => getenv('MAIL_PORT'),
461
            'username' => getenv('MAIL_USER'),
462
            'password' => getenv('MAIL_PASS'),
463
            'encryption' => NULL,
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
464
            'auth_mode' => NULL,
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
465
            'charset_iso_2022_jp' => false,
466
        ),
467
    );
468
    return $mail;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
469
}
470
471
/**
472
 * @see \Eccube\Controller\Install\InstallController::createPathYamlFile()
473
 */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
474
function getPathConfig()
0 ignored issues
show
Coding Style introduced by
Consider putting global function "getPathConfig" in a static class
Loading history...
475
{
476
    $ADMIN_ROUTE = getenv('ADMIN_ROUTE');
477
    $TEMPLATE_CODE = 'default';
478
    $USER_DATA_ROUTE = 'user_data';
479
    $ROOT_DIR = realpath(__DIR__);
480
    $ROOT_URLPATH = getenv('ROOT_URLPATH');
481
    $ROOT_PUBLIC_URLPATH = $ROOT_URLPATH.RELATIVE_PUBLIC_DIR_PATH;
482
483
    $target = array('${ADMIN_ROUTE}', '${TEMPLATE_CODE}', '${USER_DATA_ROUTE}', '${ROOT_DIR}', '${ROOT_URLPATH}', '${ROOT_PUBLIC_URLPATH}');
484
    $replace = array($ADMIN_ROUTE, $TEMPLATE_CODE, $USER_DATA_ROUTE, $ROOT_DIR, $ROOT_URLPATH, $ROOT_PUBLIC_URLPATH);
485
    $content = str_replace(
486
        $target,
487
        $replace,
488
        file_get_contents(__DIR__.'/src/Eccube/Resource/config/path.yml.dist')
489
    );
490
    return \Symfony\Component\Yaml\Yaml::parse($content);
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
491
}
492
493
/**
0 ignored issues
show
introduced by
Doc comment for parameter "$argv" missing
Loading history...
494
 * @link https://github.com/composer/windows-setup/blob/master/src/php/installer.php
495
 */
496
function setUseAnsi($argv)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "setUseAnsi" in a static class
Loading history...
497
{
498
    // --no-ansi wins over --ansi
499
    if (in_array('--no-ansi', $argv)) {
500
        define('USE_ANSI', false);
501
    } elseif (in_array('--ansi', $argv)) {
502
        define('USE_ANSI', true);
503
    } else {
504
        // On Windows, default to no ANSI, except in ANSICON and ConEmu.
505
        // Everywhere else, default to ANSI if stdout is a terminal.
506
        define(
507
            'USE_ANSI',
508
            (DIRECTORY_SEPARATOR == '\\')
509
                ? (false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'))
510
                : (function_exists('posix_isatty') && posix_isatty(1))
511
        );
512
    }
513
}
514
515
/**
0 ignored issues
show
introduced by
Doc comment for parameter "$text" missing
Loading history...
introduced by
Doc comment for parameter "$color" missing
Loading history...
introduced by
Doc comment for parameter "$newLine" missing
Loading history...
516
 * @link https://github.com/composer/windows-setup/blob/master/src/php/installer.php
517
 */
518
function out($text, $color = null, $newLine = true)
0 ignored issues
show
Coding Style introduced by
Consider putting global function "out" in a static class
Loading history...
519
{
520
    $styles = array(
0 ignored issues
show
introduced by
Add a comma after each item in a multi-line array
Loading history...
521
        'success' => "\033[0;32m%s\033[0m",
522
        'error' => "\033[31;31m%s\033[0m",
523
        'info' => "\033[33;33m%s\033[0m"
524
    );
525
    $format = '%s';
526
    if (isset($styles[$color]) && USE_ANSI) {
527
        $format = $styles[$color];
528
    }
529
    if ($newLine) {
530
        $format .= PHP_EOL;
531
    }
532
    printf($format, $text);
533
}
534