wgjr / hateoas-laravel
Laravel 响应 hateoas
1.0.5
2021-10-18 06:39 UTC
Requires (Dev)
- php: >=7.4
- ext-json: *
- laravelcollective/html: ^5.5
- orchestra/testbench: ^3.8
README
# 安装方法
composer require wgjr/hateoas-laravel
- 需要 PHP 7.4 + 其他版本
composer require wgjr/hateoas-laravel --ignore-platform-reqs
- Laravel 5.6+
如何使用类
- 在 Laravel 中添加提供者
\hateoasLaravel\HateoasLaravelServiceProvider::class
- 添加到您的类中
use use hateoasLaravel\Domain\UseCases\HateoasLaravel;
$responseFormater = new HateoasLaravel();
/**
*
* Formatted a universal response object to Hateoas response
*
* @param string $classInResponse
* @param string $hashMessage
* @param int|null $code
* @param array|null $dataResponse
* @return LaravelJsonResponse
* @throws Exception
*/
return $this->responseFormatter->formatResponse(
'login',
'login_success',
200,
[]
);