hyperf-chat/app/Controller/IndexController.php

35 lines
838 B
PHP
Raw Normal View History

2020-11-02 22:45:37 +08:00
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace App\Controller;
use Hyperf\HttpServer\Contract\ResponseInterface;
2020-11-03 14:07:54 +08:00
2020-11-02 22:45:37 +08:00
use Hyperf\Amqp\Producer;
use App\Amqp\Producer\DemoProducer;
class IndexController extends AbstractController
{
public function index(ResponseInterface $response)
{
$user = $this->request->input('user', 'Hyperf');
$method = $this->request->getMethod();
2020-11-03 14:07:54 +08:00
$producer = container()->get(Producer::class);
2020-11-02 22:45:37 +08:00
$producer->produce(new DemoProducer('test'. date('Y-m-d H:i:s')));
return [
'method' => $method,
2020-11-03 14:07:54 +08:00
'message' => "Hello {$user}."
2020-11-02 22:45:37 +08:00
];
}
}