使用更多 Hyperf 组件
<?php
use Hyperf\DB\DB;
use Hyperf\Nano\Factory\AppFactory;
require_once __DIR__ . '/vendor/autoload.php';
$app = AppFactory::create();
$app->config([
'db.default' => [
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 3306),
'database' => env('DB_DATABASE', 'hyperf'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
]
]);
$app->get('/', function(){
return DB::query('SELECT * FROM `user` WHERE gender = ?;', [1]);
});
$app->run();