NoraBear Package API Documentation

JsonRest
in package

FinalYes

JsonRest アノテーション

メソッドまたはクラスに適用して、統一されたJSONレスポンス構造を有効にします

Tags
example
use BEAR\Resource\ResourceObject;
use NoraBear\Package\Annotation\JsonRest;

class Users extends ResourceObject
{
    #[JsonRest]
    public function onGet(): static
    {
        $this->body = ['users' => [...]];
        return $this;
    }
}
// Response: {"info": {"status": "ok"}, "payload": {"users": [...]}}
Annotation
Target

("METHOD")

Target

("CLASS")

Attributes
#[Attribute]
\Attribute::TARGET_METHOD | \Attribute::TARGET_CLASS

Table of Contents

Properties

$outputNormalize  : bool

Methods

__construct()  : mixed
normalizeOutput()  : bool
出力の正規化が有効かどうか

Properties

$outputNormalize

public bool $outputNormalize = true

Methods

__construct()

public __construct([bool $outputNormalize = true ]) : mixed
Parameters
$outputNormalize : bool = true

normalizeOutput()

出力の正規化が有効かどうか

public normalizeOutput() : bool
Return values
bool

        
On this page

Search results