wayhood/hyperf-service

Installs: 166

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/wayhood/hyperf-service

dev-main 2023-04-14 10:58 UTC

This package is auto-updated.

Last update: 2025-09-29 02:44:16 UTC


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();
    }
}