Something went wrong. Try again.
A barebones implementation of an atproto PDS in PHP and Slim Framework 4.
pds php atproto
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758<?php
declare(strict_types=1);
namespace App\Application\Actions\Pds;
use App\Application\Actions\Action;use App\Application\Settings\SettingsInterface;use Psr\Log\LoggerInterface;
abstract class PdsAction extends Action{ protected SettingsInterface $settings;
public string $actionName;
public function __construct(LoggerInterface $logger, SettingsInterface $settings, string $actionName) { parent::__construct($logger); $this->settings = $settings; $this->actionName = $actionName; }
public function throwMissingKeyException(string $key): never { throw XrpcException::missingParam($this->actionName, $key); }
/** * @param array<string, mixed> $body */ protected function requireString(array $body, string $key): string { $value = $body[$key] ?? null; if (!is_string($value) || trim($value) === '') { $this->throwMissingKeyException($key); }
return $value; }
/** * @param array<string, mixed> $body */ protected function optionalString(array $body, string $key): ?string { $value = $body[$key] ?? null; if ($value === null || (is_string($value) && trim($value) === '')) { return null; } if (!is_string($value)) { throw XrpcException::invalidParam($this->actionName, "{$key} must be a string", ''); }
return $value; }}