快速开始

创建一个 PHP 文件,如 index.php 如下:

  1. <?php
  2. use Hyperf\Nano\Factory\AppFactory;
  3. require_once __DIR__ . '/vendor/autoload.php';
  4. $app = AppFactory::create();
  5. $app->get('/', function () {
  6. $user = $this->request->input('user', 'nano');
  7. $method = $this->request->getMethod();
  8. return [
  9. 'message' => "hello {$user}",
  10. 'method' => $method,
  11. ];
  12. });
  13. $app->run();

启动服务:

  1. php index.php start

简洁如此。