Skip to content

Instantly share code, notes, and snippets.

@xiaohuilam
Created December 23, 2018 19:19
Show Gist options
  • Save xiaohuilam/b42a07320e7e3ab630a21066120c477a to your computer and use it in GitHub Desktop.
Save xiaohuilam/b42a07320e7e3ab630a21066120c477a to your computer and use it in GitHub Desktop.
tenkawa+swoole
#!/usr/bin/env php
<?php
use Tsufeki\Tenkawa\Server\Tenkawa;
\Swoole\Runtime::enableCoroutine();
go(function () use ($argv) {
if (PHP_MAJOR_VERSION !== 7 || PHP_MINOR_VERSION < 1) {
fprintf(STDERR, "Tenkawa requires PHP >= 7.1\n");
exit(1);
}
$requiredExtensions = [
'pdo_sqlite' => 2,
'mbstring' => 3,
];
foreach ($requiredExtensions as $ext => $errorCode) {
if (!extension_loaded($ext)) {
fprintf(STDERR, "Tenkawa requires $ext extension\n");
exit($errorCode);
}
}
unset($requiredExtensions, $ext, $errorCode);
foreach ([__DIR__ . '/../../../autoload.php', __DIR__ . '/../autoload.php', __DIR__ . '/../vendor/autoload.php'] as $file) {
if (file_exists($file)) {
require_once $file;
break;
}
}
unset($file);
if (!class_exists(Tenkawa::class)) {
fprintf(STDERR, "Tenkawa was not properly installed\n");
exit(9);
}
Tenkawa::main($argv);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment