Skip to main content

Attributes

At a PSX controller you can describe various information using attributes. It is required that you controller method has at least a HTTP Method (one of Get, Post, Put, Patch or Delete) and a Path attribute.

class Population extends ControllerAbstract
{
#[Get]
#[Path('/population')]
public function getAll(?int $startIndex = null, ?int $count = null): Model\PopulationCollection
{
return $this->populationTable->getCollection($startIndex, $count);
}

#[Post]
#[Path('/population')]
public function create(Model\Population $payload): Model\Message
{
$id = $this->populationService->create($payload);

$message = new Model\Message();
$message->setSuccess(true);
$message->setMessage('Population record successfully created');
$message->setId($id);
return $message;
}
}

PSX tries to automatically add the missing attributes based on the defined arguments and return types. If you like to explicit define the values you can use the following attributes.

AttributeTargetExampleDescription
AuthorizationClass/Method#[Authorization(true)]The operation needs authorization
DeleteClass/Method#[Delete()]HTTP DELETE method
DeprecatedClass/Method#[Deprecated(true)]The operation is deprecated
DescriptionClass/Method#[Description("foobar")]Description of this operation
ExcludeClass/Method#[Exclude]Whether to exclude this operation
GetClass/Method#[Get()]HTTP GET method
IncomingClass/Method#[Incoming()]Describes incoming request data
OperationIdClass/Method#[OperationId("my_method")]The operation id
OutgoingClass/Method#[Outgoing()]Describes outgoing response data
PatchClass/Method#[Patch()]HTTP PATCH method
PathClass/Method#[Path("/endpoint")]The endpoint path
PathParamClass/Method#[PathParam()]Describes variable path parameters
PostClass/Method#[Post()]HTTP POST method
PutClass/Method#[Put()]HTTP PUT method
QueryParamClass/Method#[QueryParam()]Describes query parameters
SecurityClass/Method#[Security(["scope"])]The scopes assigned to this operations
TagsClass/Method#[Tags(["tag"])]Tags assigned to this operation