wayhood / hyperf-service
dev-main
2023-04-14 10:58 UTC
Requires
- php: >=8.0
README
A Service Annotation for Hyperf
Example
auto set dependencies
TestSerivce -> TestServiceImpl
<?php
namespace App\Service;
interface TestService
{
public function getTest(): string;
}
<?php
namespace App\Service\Impl;
use App\Service\TestService;
use Wayhood\Service\Annotation\Service;
#[Service]
class TestServiceImpl implements TestService
{
public function getTest(): string {
return "abc";
}
}
namespace App\Controller;
use App\Service\TestService;
use Hyperf\Di\Annotation\Inject;
class IndexController extends AbstractController
{
#[Inject]
protected TestService $testService;
public function index()
{
return $this->testService->getTest();
}
}