Resource
A resource corresponding to a URI decides its state and returns it.
final class Profile extends ResourceObject
{
public function onGet(int $id): static
{
$this->body = $this->profileQuery->item($id);
return $this;
}
}
Dependency Injection
Required dependencies are made explicit in the constructor.
public function __construct(
private readonly ProfileQuery $profileQuery,
private readonly ClockInterface $clock,
) {
}
AOP
Cross-cutting concerns are offloaded to attributes and Interceptors.
#[Transactional]
#[Cacheable(expirySecond: 30)]
public function onPost(string $name): static
{
$this->body = $this->command->create($name);
return $this;
}
Hypermedia
Declare the next reachable resources as links.
#[Link(rel: 'orders', href: 'app://self/orders{?id}')]
#[Embed(rel: 'profile', src: 'app://self/profile{?id}')]
public function onGet(int $id): static
{
return $this;
}