属性参考
本文档由脚本自动生成,请勿手动编辑
Kuiper 框架使用 PHP 8 Attribute(属性)进行声明式配置,本文档按包列出全部 52 个可用属性及其构造参数。
目录
依赖注入
Bean
命名空间: kuiper\di\attribute
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$name | ?string | null |
用法:
use kuiper\di\attribute\Bean;
class ExampleService
{
#[Bean(name: '...')]
public function handle(): void
{
}
}Command
命名空间: kuiper\di\attribute
命令行命令(v0.8 风格)。
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$name | string | '' |
用法:
use kuiper\di\attribute\Command;
#[Command(name: '...')]
class ExampleService
{
}Component
命名空间: kuiper\di\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$value | ?string | null |
用法:
use kuiper\di\attribute\Component;
#[Component(value: '...')]
class ExampleService
{
}ConditionalOnClass
命名空间: kuiper\di\attribute
仅当指定类/接口存在时注册该 Bean 或整个配置类.
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$className | array|string | — |
用法:
use kuiper\di\attribute\ConditionalOnClass;
class ExampleService
{
#[ConditionalOnClass(className: '...')]
public function handle(): void
{
}
}ConditionalOnMissingBean
命名空间: kuiper\di\attribute
仅当容器中还没有指定 Bean 定义时注册该 Bean.
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$beanName | string | — | Bean 名称(通常是类名或接口名) |
用法:
use kuiper\di\attribute\ConditionalOnMissingBean;
class ExampleService
{
#[ConditionalOnMissingBean(beanName: '...')]
public function handle(): void
{
}
}ConditionalOnMissingClass
命名空间: kuiper\di\attribute
仅当指定类/接口不存在时注册该 Bean.
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$className | string | — |
用法:
use kuiper\di\attribute\ConditionalOnMissingClass;
class ExampleService
{
#[ConditionalOnMissingClass(className: '...')]
public function handle(): void
{
}
}ConditionalOnProperty
命名空间: kuiper\di\attribute
仅当配置项存在(且可选地等于指定值)时注册该 Bean.
可用位置: method(可重复使用)
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$name | string | — | |
$hasValue | mixed | null |
用法:
use kuiper\di\attribute\ConditionalOnProperty;
class ExampleService
{
#[ConditionalOnProperty(name: '...')]
public function handle(): void
{
}
}Configuration
命名空间: kuiper\di\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$dependsOn | array | [] |
用法:
use kuiper\di\attribute\Configuration;
#[Configuration]
class ExampleService
{
}Service
命名空间: kuiper\di\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$value | ?string | null | |
$description | ?string | null |
用法:
use kuiper\di\attribute\Service;
#[Service(value: '...')]
class ExampleService
{
}Web
Controller
命名空间: kuiper\web\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$value | ?string | null |
用法:
use kuiper\web\attribute\Controller;
#[Controller(value: '...')]
class ExampleService
{
}CsrfToken
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$repeatOk | bool | — |
用法:
use kuiper\web\attribute\CsrfToken;
class ExampleService
{
#[CsrfToken(repeatOk: true)]
public function handle(): void
{
}
}DeleteMapping
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$mapping | array|string | — | |
$name | string | '' |
用法:
use kuiper\web\attribute\DeleteMapping;
class ExampleService
{
#[DeleteMapping(mapping: '...')]
public function handle(): void
{
}
}ErrorHandler
命名空间: kuiper\web\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$exceptions | array|string | — | Exception class name |
用法:
use kuiper\web\attribute\ErrorHandler;
#[ErrorHandler(exceptions: '...')]
class ExampleService
{
}GetMapping
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$mapping | array|string | — | |
$name | string | '' |
用法:
use kuiper\web\attribute\GetMapping;
class ExampleService
{
#[GetMapping(mapping: '...')]
public function handle(): void
{
}
}LoginOnly
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$priority | int | 101 |
用法:
use kuiper\web\attribute\LoginOnly;
class ExampleService
{
#[LoginOnly(priority: 1)]
public function handle(): void
{
}
}OptionsMapping
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$mapping | array|string | — | |
$name | string | '' |
用法:
use kuiper\web\attribute\OptionsMapping;
class ExampleService
{
#[OptionsMapping(mapping: '...')]
public function handle(): void
{
}
}PatchMapping
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$mapping | array|string | — | |
$name | string | '' |
用法:
use kuiper\web\attribute\PatchMapping;
class ExampleService
{
#[PatchMapping(mapping: '...')]
public function handle(): void
{
}
}PostMapping
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$mapping | array|string | — | |
$name | string | '' |
用法:
use kuiper\web\attribute\PostMapping;
class ExampleService
{
#[PostMapping(mapping: '...')]
public function handle(): void
{
}
}PreAuthorize
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$requiredAuthorities | array | — | |
$anyAuthorities | array | [] |
用法:
use kuiper\web\attribute\PreAuthorize;
class ExampleService
{
#[PreAuthorize(requiredAuthorities: [])]
public function handle(): void
{
}
}PutMapping
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$mapping | array|string | — | |
$name | string | '' |
用法:
use kuiper\web\attribute\PutMapping;
class ExampleService
{
#[PutMapping(mapping: '...')]
public function handle(): void
{
}
}RateLimit
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$priority | int | 512 |
用法:
use kuiper\web\attribute\RateLimit;
class ExampleService
{
#[RateLimit(priority: 1)]
public function handle(): void
{
}
}RequestMapping
命名空间: kuiper\web\attribute
可用位置: class / method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$mapping | array|string | — | The path mapping URIs. type is string|string[]. |
$name | string | '' | assign a name to this mapping |
$method | array | [] | the HTTP request methods to map to |
用法:
use kuiper\web\attribute\RequestMapping;
class ExampleService
{
#[RequestMapping(mapping: '...')]
public function handle(): void
{
}
}数据库
Column
命名空间: kuiper\db\attribute
可用位置: property
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$name | string | — |
用法:
use kuiper\db\attribute\Column;
class ExampleEntity
{
#[Column(name: '...')]
private string $field;
}Convert
命名空间: kuiper\db\attribute
可用位置: property
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$converter | string | — |
用法:
use kuiper\db\attribute\Convert;
class ExampleEntity
{
#[Convert(converter: '...')]
private string $field;
}CreationTimestamp
命名空间: kuiper\db\attribute
可用位置: property
该属性没有构造参数。
用法:
use kuiper\db\attribute\CreationTimestamp;
class ExampleEntity
{
#[CreationTimestamp]
private string $field;
}Embeddable
命名空间: kuiper\db\attribute
可用位置: class
该属性没有构造参数。
用法:
use kuiper\db\attribute\Embeddable;
#[Embeddable]
class ExampleService
{
}Entity
命名空间: kuiper\db\attribute
可用位置: class
该属性没有构造参数。
用法:
use kuiper\db\attribute\Entity;
#[Entity]
class ExampleService
{
}Enumerated
命名空间: kuiper\db\attribute
可用位置: property
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$value | string | self::ORDINAL |
用法:
use kuiper\db\attribute\Enumerated;
class ExampleEntity
{
#[Enumerated(value: '...')]
private string $field;
}GeneratedValue
命名空间: kuiper\db\attribute
可用位置: property
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$type | string | 'AUTO' |
用法:
use kuiper\db\attribute\GeneratedValue;
class ExampleEntity
{
#[GeneratedValue(type: '...')]
private string $field;
}Id
命名空间: kuiper\db\attribute
可用位置: property
该属性没有构造参数。
用法:
use kuiper\db\attribute\Id;
class ExampleEntity
{
#[Id]
private string $field;
}NaturalId
命名空间: kuiper\db\attribute
可用位置: property
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$name | ?string | null |
用法:
use kuiper\db\attribute\NaturalId;
class ExampleEntity
{
#[NaturalId(name: '...')]
private string $field;
}Repository
命名空间: kuiper\db\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$entityClass | string | — |
用法:
use kuiper\db\attribute\Repository;
#[Repository(entityClass: '...')]
class ExampleService
{
}ShardKey
命名空间: kuiper\db\attribute
可用位置: property
该属性没有构造参数。
用法:
use kuiper\db\attribute\ShardKey;
class ExampleEntity
{
#[ShardKey]
private string $field;
}Table
命名空间: kuiper\db\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$name | string | — |
用法:
use kuiper\db\attribute\Table;
#[Table(name: '...')]
class ExampleService
{
}Transient
命名空间: kuiper\db\attribute
可用位置: property
该属性没有构造参数。
用法:
use kuiper\db\attribute\Transient;
class ExampleEntity
{
#[Transient]
private string $field;
}UpdateTimestamp
命名空间: kuiper\db\attribute
可用位置: property
该属性没有构造参数。
用法:
use kuiper\db\attribute\UpdateTimestamp;
class ExampleEntity
{
#[UpdateTimestamp]
private string $field;
}RPC
RpcClient
命名空间: kuiper\rpc\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$service | string | '' | |
$version | string | '' | |
$ns | string | '' | |
$serialization | string | 'jsonrpc' | |
$name | ?string | null | |
$protocol | string | '' | |
$endpoint | string | '' |
用法:
use kuiper\rpc\attribute\RpcClient;
#[RpcClient(service: '...')]
class ExampleService
{
}RpcService
命名空间: kuiper\rpc\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$ns | string | '' | |
$service | string | '' | |
$version | string | '' | |
$name | ?string | null |
用法:
use kuiper\rpc\attribute\RpcService;
#[RpcService(ns: '...')]
class ExampleService
{
}序列化
SerializeIgnore
命名空间: kuiper\serializer\attribute
Mark field not serialize.
可用位置: method / property
该属性没有构造参数。
用法:
use kuiper\serializer\attribute\SerializeIgnore;
class ExampleService
{
#[SerializeIgnore]
public function handle(): void
{
}
}SerializeName
命名空间: kuiper\serializer\attribute
可用位置: method / property / parameter
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$name | string | — |
用法:
use kuiper\serializer\attribute\SerializeName;
class ExampleService
{
#[SerializeName(name: '...')]
public function handle(): void
{
}
}事件
Async
命名空间: kuiper\event\attribute
可用位置: class
该属性没有构造参数。
用法:
use kuiper\event\attribute\Async;
#[Async]
class ExampleService
{
}EventListener
命名空间: kuiper\event\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$eventName | ?string | null |
用法:
use kuiper\event\attribute\EventListener;
#[EventListener(eventName: '...')]
class ExampleService
{
}HTTP 客户端
DeleteMapping
命名空间: kuiper\http\client\attribute
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$path | string | — |
用法:
use kuiper\http\client\attribute\DeleteMapping;
class ExampleService
{
#[DeleteMapping(path: '...')]
public function handle(): void
{
}
}GetMapping
命名空间: kuiper\http\client\attribute
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$path | string | — |
用法:
use kuiper\http\client\attribute\GetMapping;
class ExampleService
{
#[GetMapping(path: '...')]
public function handle(): void
{
}
}HttpClient
命名空间: kuiper\http\client\attribute
可用位置: class
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$service | string | '' | |
$version | string | '' | |
$namespace | string | '' | |
$protocol | string | '' | |
$endpoint | string | '' | |
$url | string | '' | |
$path | string | '' | |
$responseParser | string | '' |
用法:
use kuiper\http\client\attribute\HttpClient;
#[HttpClient(service: '...')]
class ExampleService
{
}HttpHeader
命名空间: kuiper\http\client\attribute
可用位置: class / method / parameter(可重复使用)
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$name | string | — | |
$value | string | '' |
用法:
use kuiper\http\client\attribute\HttpHeader;
class ExampleService
{
#[HttpHeader(name: '...')]
public function handle(): void
{
}
}OptionsMapping
命名空间: kuiper\http\client\attribute
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$path | string | — |
用法:
use kuiper\http\client\attribute\OptionsMapping;
class ExampleService
{
#[OptionsMapping(path: '...')]
public function handle(): void
{
}
}PatchMapping
命名空间: kuiper\http\client\attribute
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$path | string | — |
用法:
use kuiper\http\client\attribute\PatchMapping;
class ExampleService
{
#[PatchMapping(path: '...')]
public function handle(): void
{
}
}PostMapping
命名空间: kuiper\http\client\attribute
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$path | string | — |
用法:
use kuiper\http\client\attribute\PostMapping;
class ExampleService
{
#[PostMapping(path: '...')]
public function handle(): void
{
}
}PutMapping
命名空间: kuiper\http\client\attribute
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$path | string | — |
用法:
use kuiper\http\client\attribute\PutMapping;
class ExampleService
{
#[PutMapping(path: '...')]
public function handle(): void
{
}
}QueryParam
命名空间: kuiper\http\client\attribute
可用位置: parameter
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$name | ?string | null |
用法:
use kuiper\http\client\attribute\QueryParam;
class ExampleService
{
public function handle(#[QueryParam(name: '...')] string $value): void
{
}
}RequestMapping
命名空间: kuiper\http\client\attribute
可用位置: method
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$path | string | — | |
$method | string | '' |
用法:
use kuiper\http\client\attribute\RequestMapping;
class ExampleService
{
#[RequestMapping(path: '...')]
public function handle(): void
{
}
}