Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyao committed Dec 13, 2024
1 parent ceab713 commit d7e5d85
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 6 additions & 2 deletions bin/cli-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* @license https://github.com/next-laboratory/next/blob/master/LICENSE
*/

date_default_timezone_set('PRC');
define('BASE_PATH', dirname(__DIR__) . '/');
require_once BASE_PATH . 'app/bootstrap.php';

echo <<<EOT
,--. ,--. ,--. ,------. ,--. ,--.,------.
| ,'.| | ,---. ,--. ,--.,-' '-.| .--. '| '--' || .--. '
Expand All @@ -18,8 +22,8 @@
EOT;

$host = '0.0.0.0';
$port = '8989';
$host = env('SERVER_HOST', '0.0.0.0');
$port = (int)env('SERVER_PORT', 8989);
printf("System Name: %s\n", strtolower(PHP_OS));
printf("PHP Version: %s\n", PHP_VERSION);
printf("Listen Addr: %s\n", $host . ':' . $port);
Expand Down
18 changes: 16 additions & 2 deletions bin/swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

date_default_timezone_set('PRC');
define('BASE_PATH', dirname(__DIR__) . '/');
require_once BASE_PATH . 'vendor/autoload.php';
require_once BASE_PATH . 'app/bootstrap.php';

$server = new Server('0.0.0.0', 8989);
$host = env('SERVER_HOST', '0.0.0.0');
$port = (int)env('SERVER_PORT', 8989);
$server = new Server($host, $port);
$routeDispatcher = require_once base_path('app/router.php');

$server->on('request', function (Request $request, Response $response) use ($routeDispatcher) {
Expand All @@ -38,4 +40,16 @@
}
});

echo <<<EOT
,--. ,--. ,--. ,------. ,--. ,--.,------.
| ,'.| | ,---. ,--. ,--.,-' '-.| .--. '| '--' || .--. '
| |' ' || .-. : \ `' / '-. .-'| '--' || .--. || '--' |
| | ` |\ --. / /. \ | | | | --' | | | || | --'
`--' `--' `----''--' '--' `--' `--' `--' `--'`--'
EOT;

printf("System Name: %s\n", strtolower(PHP_OS));
printf("PHP Version: %s\n", PHP_VERSION);
printf("Listen Addr: %s\n", $host . ':' . $port);
$server->start();

0 comments on commit d7e5d85

Please sign in to comment.