Skip to content

Commit 12fc0ef

Browse files
authored
Merge pull request #23 from Rivsen/patch-1
Remove timezone settings, it's not a common case
2 parents 4d2960d + cdc3803 commit 12fc0ef

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

bin/hyperf.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
ini_set('display_startup_errors', 'on');
66

77
error_reporting(E_ALL);
8-
date_default_timezone_set('Asia/Shanghai');
98

109
! defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1));
1110
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL);

installer/OptionalPackages.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ public function __construct(IOInterface $io, Composer $composer, string $project
120120
$this->installerSource = realpath(__DIR__) . '/';
121121
}
122122

123+
public function installHyperfScript()
124+
{
125+
$ask[] = "\n <question>What time zone do you want to setup ?</question>\n";
126+
$ask[] = " [<comment>n</comment>] Default time zone for php.ini\n";
127+
$ask[] = "Make your selection or type a time zone name, like Asia/Shanghai (n):\n";
128+
$answer = $this->io->ask(implode('', $ask), 'n');
129+
130+
if (! empty($answer) || $answer != 'n') {
131+
$content = file_get_contents($this->installerSource . '/resources/bin/hyperf.php');
132+
$content = str_replace('%TIME_ZONE%', $answer, $content);
133+
file_put_contents($this->projectRoot . '/bin/hyperf.php', $content);
134+
}
135+
}
136+
123137
/**
124138
* Create data and cache directories, if not present.
125139
*

installer/Script.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static function install(Event $event)
2424

2525
$installer->setupRuntimeDir();
2626
$installer->removeDevDependencies();
27+
$installer->installHyperfScript();
2728
$installer->promptForOptionalPackages();
2829
$installer->updateRootPackage();
2930
$installer->removeInstallerFromDefinition();

installer/resources/bin/hyperf.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
ini_set('display_errors', 'on');
5+
ini_set('display_startup_errors', 'on');
6+
7+
error_reporting(E_ALL);
8+
date_default_timezone_set('%TIME_ZONE%');
9+
10+
! defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1));
11+
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL);
12+
13+
require BASE_PATH . '/vendor/autoload.php';
14+
15+
// Self-called anonymous function that creates its own scope and keep the global namespace clean.
16+
(function () {
17+
/** @var \Psr\Container\ContainerInterface $container */
18+
$container = require BASE_PATH . '/config/container.php';
19+
20+
$application = $container->get(\Hyperf\Contract\ApplicationInterface::class);
21+
$application->run();
22+
})();

0 commit comments

Comments
 (0)