API reference (omnitrix/core)
Public classes and methods, generated from the source. Classes and methods marked @internal are implementation details and are not listed.
Omnitrix
Application (class)
The developer-facing application: configuration, routes, middleware, run.
static create(array $config, ?Psr\Log\LoggerInterface $logger = NULL, ?Omnitrix\Core\Runtime\Exception\ExceptionHandlerInterface $exceptionHandler = NULL): Omnitrix\Applicationget(string $pattern, mixed $handler): Omnitrix\Routing\Routepost(string $pattern, mixed $handler): Omnitrix\Routing\Routeput(string $pattern, mixed $handler): Omnitrix\Routing\Routepatch(string $pattern, mixed $handler): Omnitrix\Routing\Routedelete(string $pattern, mixed $handler): Omnitrix\Routing\Routeoptions(string $pattern, mixed $handler): Omnitrix\Routing\Routeany(string $pattern, mixed $handler): Omnitrix\Routing\Routemap(array $methods, string $pattern, mixed $handler): Omnitrix\Routing\Routegroup(string $prefix, callable $define, array $middleware = …): Omnitrix\Applicationroutes(string $file): Omnitrix\Application— Loads a route file. The file receives$app(this application) and$routerin scope,middleware(Omnitrix\Http\Middleware\MiddlewareInterface|callable ...$middleware): Omnitrix\Application— Global middleware applied to every route, in order.router(): Omnitrix\Routing\Routerlogger(): Psr\Log\LoggerInterface— The application logger (PSR-3). Structured JSON on stderr unless one was passed to create().exceptionHandler(): Omnitrix\Core\Runtime\Exception\ExceptionHandlerInterface— Receives every exception caught at a coroutine or request boundary.config(): arrayisDebug(): boolonWorkerStart(callable $listener): Omnitrix\ApplicationonWorkerStop(callable $listener): Omnitrix\ApplicationconfigureContainer(callable $configurator): Omnitrix\Applicationbuild(): OpenSwoole\Http\Server— Builds the server without starting it.run(): void— Starts the server (blocking).stop(): voidenableMetrics(string $path = '/metrics', array $middleware = …): Omnitrix\Application— Records request counts and latency histograms (shared across workers) and serves them inhealth(string $prefix = '/health', array $checks = …, float $timeout = 2.0): Omnitrix\Application— Registers{$prefix}/live(process is up) and{$prefix}/ready(dependencies answer).cpu(array $jobs, int $workers = 2, float $timeout = 30.0, int $maxPending = 64): Omnitrix\Application— Enables the CPU worker pool:$workersdedicated processes, supervised and restarted bywithServices(callable $body): mixed— Runs$bodywith the application's services (database, Redis, cache, queue producer,
Omnitrix\Config
Config (class)
Loads a configuration directory: every *.php file returns an array and becomes the section
static load(string $directory): arraystatic get(array $config, string $path, mixed $default = NULL): mixed— Reads a dotted path (queue.jobs) from a configuration array.static string(array $config, string $path, string $default): string
Env (class)
Environment variables for configuration. Read once at boot (in the master) to build the
static load(string $path): int— Loads a .env file into the process environment without overriding existing variables.static get(string $name, ?string $default = NULL): ?stringstatic required(string $name): stringstatic int(string $name, int $default): intstatic bool(string $name, bool $default): bool
Omnitrix\Console
Command (abstract class)
Base class for project commands. Gives access to the project ({@see Console::path()}) and to
__construct(?Omnitrix\Console\Console $console = NULL)
Omnitrix\Console\Commands
AboutCommand (class)
MakeCommand (abstract class)
Base class for the generators. Class names may contain sub-namespaces with / or \
MakeControllerCommand (class)
MakeJobCommand (class)
MakeMiddlewareCommand (class)
MakeMigrationCommand (class)
MakeModelCommand (class)
MakeSeederCommand (class)
MigrateCommand (class)
MigrateFreshCommand (class)
MigrateResetCommand (class)
MigrateRollbackCommand (class)
MigrateStatusCommand (class)
MigrationCommand (abstract class)
Shared plumbing for the migration and seeding commands.
QueueWorkCommand (class)
Processes background jobs. Job names map to handlers in config/queue.php:
RoutesCommand (class)
SeedCommand (class)
ServeCommand (class)
Starts the HTTP server in the foreground. --host, --port and --workers set the
Omnitrix\Console
Console (class)
The project command line (php omnitrix). A project is a directory with a bootstrap.php
__construct(string $basePath)run(?Symfony\Component\Console\Input\InputInterface $input = NULL, ?Symfony\Component\Console\Output\OutputInterface $output = NULL): int— Runs the command line and returns the exit code.add(Omnitrix\Console\Command $command): Omnitrix\Console\Console— Adds a project command (a subclass of {@see Command}).application(): Symfony\Component\Console\Applicationapp(): Omnitrix\Application— The project's application, built bybootstrap.phpon first use.path(string ...$segments): stringstatic version(): string
Omnitrix\Core\Cache
Cache (class)
Application cache over a key-value store.
__construct(Omnitrix\Core\Cache\KeyValueStoreInterface $store, string $prefix = 'cache:', int $defaultTtl = 3600)get(string $key, mixed $default = NULL): mixedset(string $key, mixed $value, ?int $ttl = NULL): booladd(string $key, mixed $value, ?int $ttl = NULL): bool— Stores only when the key is absent (atomic).forever(string $key, mixed $value): boolhas(string $key): booldelete(string ...$keys): intgetMany(array $keys): arrayremember(string $key, ?int $ttl, callable $compute): mixed— Returns the cached value or computes, stores and returns it.increment(string $key, int $by = 1): intdecrement(string $key, int $by = 1): intttl(string $key): intkey(string $key): string
KeyValueStoreInterface (interface)
Minimal string store the cache is built on (Redis in production, in-memory in tests).
get(string $key): ?stringset(string $key, string $value, ?int $ttl = NULL): boolsetIfAbsent(string $key, string $value, ?int $ttl = NULL): boolgetMany(array $keys): arraydelete(string ...$keys): intexists(string $key): boolincrement(string $key, int $by = 1): intdecrement(string $key, int $by = 1): intexpire(string $key, int $seconds): boolttl(string $key): int
Omnitrix\Core\Concurrency
Async (class)
Structured concurrency combinators over {@see TaskScope}.
static all(array $tasks, ?float $timeout = NULL, ?int $concurrency = NULL, ?Omnitrix\Core\Concurrency\CancellationToken $parent = NULL): array— Runs all callables concurrently and returns their results keyed like$tasks.static allSettled(array $tasks, ?float $timeout = NULL, ?int $concurrency = NULL, ?Omnitrix\Core\Concurrency\CancellationToken $parent = NULL): array— Runs all callables concurrently and reports every outcome; individual failures do notstatic race(array $tasks, ?float $timeout = NULL, ?Omnitrix\Core\Concurrency\CancellationToken $parent = NULL): mixed— Returns the result of the first task to complete successfully and cancels the rest.static withTimeout(callable $body, float $timeout, ?Omnitrix\Core\Concurrency\CancellationToken $parent = NULL): mixed— Runs$bodyin a child task bounded by$timeoutseconds; on expiry the task isstatic scope(callable $body, ?int $concurrency = NULL, ?Omnitrix\Core\Concurrency\CancellationToken $parent = NULL): mixed— Runs$bodywith a scope that is closed (remaining tasks cancelled and awaited) whenstatic sleep(float $seconds): void— Cooperative, cancellable sleep.
CancellationToken (class)
Cooperative cancellation signal.
static none(): Omnitrix\Core\Concurrency\CancellationTokenisCancelled(): boolreason(): ?stringthrowIfCancelled(): voidonCancel(callable $callback): void— Registers a callback; runs immediately if already cancelled. @param callable(string|null): void $callbackattach(int $cid): void— Attaches a coroutine that will be interrupted on cancel.detach(int $cid): voidcreateChild(): Omnitrix\Core\Concurrency\CancellationToken— A token that is cancelled when this one is (but not the other way round).cancel(?string $reason = NULL): void— Idempotent.
CancelledException (class)
The operation was cancelled through its {@see CancellationToken}.
Outcome (class)
Result of one task in {@see Async::allSettled()}: fulfilled with a value or rejected with a throwable.
static fulfilled(mixed $value): Omnitrix\Core\Concurrency\Outcomestatic rejected(Throwable $reason, bool $cancelled = false): Omnitrix\Core\Concurrency\OutcomeisRejected(): boolget(): mixed— The value, or throws the rejection reason.
Semaphore (class)
Counting semaphore for bounding concurrency across coroutines (permits are channel tokens).
__construct(int $limit)acquire(?float $timeout = NULL, ?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): void— Waits for a permit. Throws {@see TimeoutException} after$timeoutseconds orrelease(): voidwithPermit(callable $fn, ?float $timeout = NULL, ?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): mixed— Runs$fnwhile holding a permit.available(): intinUse(): intpeak(): int
Task (class)
A unit of concurrent work running in its own coroutine, owned by a {@see TaskScope}.
static start(string|int $key, callable $body, Omnitrix\Core\Concurrency\CancellationToken $parentToken, ?Omnitrix\Core\Concurrency\Semaphore $semaphore = NULL, ?callable $onSettle = NULL): Omnitrix\Core\Concurrency\Task— Starts the task immediately (the coroutine is created now; it runs until its firststate(): Omnitrix\Core\Concurrency\TaskStateisDone(): booltoken(): Omnitrix\Core\Concurrency\CancellationTokencoroutineId(): intcancel(?string $reason = NULL): void— Requests cancellation; the task settles as Cancelled once its coroutine unwinds.await(?float $timeout = NULL): mixed— Waits for completion and returns the result; rethrows the task's failure, throwsjoin(?float $timeout = NULL): bool— Waits for the task to settle without throwing its failure. Returns false on timeout.result(): mixedfailure(): ?Throwable
TaskScope (class)
Structured concurrency scope: every task spawned here is joined or cancelled before the
__construct(?Omnitrix\Core\Concurrency\CancellationToken $parent = NULL, ?int $concurrency = NULL)token(): Omnitrix\Core\Concurrency\CancellationTokenspawn(callable $body, string|int|null $key = NULL): Omnitrix\Core\Concurrency\Task— Starts a task.$bodyreceives the scope's cancellation token.nextSettled(?float $timeout = NULL): ?Omnitrix\Core\Concurrency\Task— Returns the next task to settle (completion order), or null when every spawned tasktasks(): arraycount(): intcancel(?string $reason = NULL): void— Cancels every task (idempotent).join(?float $timeout = NULL): bool— Waits for all tasks to settle (success, failure or cancellation). Returns false if theclose(float $graceSeconds = 5.0): int— Closes the scope: cancels unfinished tasks and waits for them to unwind. After this norunning(): array— Coroutine ids of tasks that are still running (diagnostics).
TaskState (enum)
static cases(): arraystatic from(string|int $value): staticstatic tryFrom(string|int $value): ?static
TimeoutException (class)
A deadline passed before the awaited work completed.
Omnitrix\Core\Container
Container (class)
Small explicit PSR-11 container (no autowiring, no reflection).
bind(string $id, callable $factory): void— Registers a factory that produces a new instance on everyget().singleton(string $id, callable $factory): void— Registers a factory whose first result is cached for the container's lifetime.instance(string $id, mixed $instance): void— Registers an existing instance.has(string $id): boolget(string $id): mixedgetTyped(string $id, string $class): object— Typed accessor: resolves$idand asserts the instance is a$class.ids(): array
ContainerException (class)
NotFoundException (class)
Omnitrix\Core\Database\Config
DatabaseConfig (class)
Validated settings of one named database connection (the database config section).
static fromArray(array $config, string $name = 'default'): Omnitrix\Core\Database\Config\DatabaseConfig
PoolConfig (class)
Pool sizing and lifecycle limits (seconds; 0 disables a timeout).
__construct(int $min, int $max, float $acquireTimeout, float $idleTimeout, float $maxLifetime, float $validationInterval, float $evictionInterval)
Omnitrix\Core\Database\Connection
PdoConnection (class)
{@see ConnectionInterface} over PDO + mysqlnd. Under OpenSwoole runtime hooks every network
__construct(?PDO $pdo, string $id, $applyStatementTimeout, int $statementCacheSize = 64)id(): stringselect(string $sql, array $bindings = …): arrayexecute(string $sql, array $bindings = …): intinsert(string $sql, array $bindings = …): intbeginTransaction(): voidcommit(): voidrollBack(): voidinTransaction(): boolsetStatementTimeout(float $seconds): voidping(): boolisBroken(): boolmarkBroken(): voidcreatedAt(): floatlastUsedAt(): floattouch(): voidclose(): voidcachedStatements(): int— Number of cached prepared statements (diagnostics).
Omnitrix\Core\Database\Contracts
ConnectionInterface (interface)
One physical database connection. Not coroutine-safe: a connection is used by exactly one
id(): string— Stable identifier for logs and pool bookkeeping.select(string $sql, array $bindings = …): array— Runs a statement that returns rows.execute(string $sql, array $bindings = …): int— Runs a statement without a result set; returns the affected row count.insert(string $sql, array $bindings = …): int— Runs an INSERT and returns the generated id (0 when none).beginTransaction(): voidcommit(): voidrollBack(): voidinTransaction(): boolsetStatementTimeout(float $seconds): void— Server-side statement time limit for subsequent statements (seconds, 0 = unlimited).ping(): bool— Cheap liveness check (SELECT 1); false when the connection is unusable.isBroken(): bool— True once the connection must not be reused (lost, interrupted, in unknown state).markBroken(): voidcreatedAt(): floatlastUsedAt(): floattouch(): voidclose(): void
DriverInterface (interface)
Creates physical connections for one database technology.
name(): stringconnect(Omnitrix\Core\Database\Config\DatabaseConfig $config): Omnitrix\Core\Database\Contracts\ConnectionInterfacegrammar(): Omnitrix\Core\Database\Contracts\GrammarInterface
GrammarInterface (interface)
SQL dialect specifics used by the query builder.
wrap(string $identifier): string— Quotes an identifier such asusersoru.name(*is passed through).wrapTable(string $table): string— Quotes a table name, optionally with an alias ("users as u").parameter(): string— Placeholder for one bound value.compileLimitOffset(?int $limit, ?int $offset): stringsupportsReturning(): bool
Omnitrix\Core\Database
Database (class)
One named database: its pool, grammar and transaction manager. Worker-scoped.
__construct(Omnitrix\Core\Database\Config\DatabaseConfig $config, Omnitrix\Core\Database\Contracts\DriverInterface $driver, ?Psr\Log\LoggerInterface $logger = NULL)warmUp(): voidpool(): Omnitrix\Core\Database\Pool\ConnectionPoolstats(): Omnitrix\Core\Database\Pool\PoolStatstable(string $table): Omnitrix\Core\Database\Query\Builderquery(): Omnitrix\Core\Database\Query\Builderselect(string $sql, array $bindings = …): arrayselectOne(string $sql, array $bindings = …): ?arrayexecute(string $sql, array $bindings = …): intinsert(string $sql, array $bindings = …): inttransaction(callable $callback, int $attempts = 1): mixedacquire(?float $timeout = NULL): Omnitrix\Core\Database\Pool\PooledConnection— Leases a connection to the caller for several statements (e.g. a cursor); the callerclose(float $drainTimeout = 10.0): int— Graceful shutdown of the pool.
DatabaseManager (class)
Registry of named databases for one worker. Built from the database config section, which
__construct(array $section, ?Psr\Log\LoggerInterface $logger = NULL)registerDriver(string $name, Omnitrix\Core\Database\Contracts\DriverInterface $driver): voidconnection(?string $name = NULL): Omnitrix\Core\Database\Databasetable(string $table, ?string $connection = NULL): Omnitrix\Core\Database\Query\Buildernames(): arraywarmUp(): void— Opens the configured minimum connections of every database.close(float $drainTimeout = 10.0): int— Drains and closes every pool. @return int leased connections that did not return in time
Omnitrix\Core\Database\Driver\MySQL
MySqlDriver (class)
MySQL / MariaDB driver on pdo_mysql (mysqlnd).
__construct()name(): stringgrammar(): Omnitrix\Core\Database\Contracts\GrammarInterfaceconnect(Omnitrix\Core\Database\Config\DatabaseConfig $config): Omnitrix\Core\Database\Contracts\ConnectionInterface
MySqlGrammar (class)
MySQL/MariaDB identifier quoting and dialect fragments.
wrap(string $identifier): stringwrapTable(string $table): stringparameter(): stringcompileLimitOffset(?int $limit, ?int $offset): stringsupportsReturning(): bool
Omnitrix\Core\Database\Exception
ConnectionException (class)
The connection could not be established or was lost. The pool discards the connection and
ConstraintViolationException (class)
Integrity constraint violation.
DatabaseException (class)
Base class of every database error raised by Omnitrix.
DeadlockException (class)
Deadlock detected; the transaction was rolled back and may be retried.
ErrorClassifier (class)
Maps PDO/MySQL errors to the framework exception hierarchy so callers (and the pool) can
static classify(PDOException $e, string $sql = '', array $bindings = …): Omnitrix\Core\Database\Exception\DatabaseExceptionstatic isConnectionError(?string $sqlState, int $driverCode, string $message): bool
LockWaitTimeoutException (class)
Lock wait timeout exceeded.
OwnershipViolationException (class)
A pooled connection was used from a coroutine that does not own it, or after release.
PoolExhaustedException (class)
No connection became available within the acquisition timeout (backpressure signal).
QueryException (class)
A statement failed. Carries the SQL (truncated) and SQLSTATE; bindings are never included.
__construct(string $message, string $sql, ?string $sqlState, int $driverCode, int $bindingCount, ?Throwable $previous = NULL)sql(): stringsqlState(): ?stringdriverCode(): intbindingCount(): intstatic describe(string $sql, array $bindings): string
QueryTimeoutException (class)
Statement exceeded its time limit.
TransactionException (class)
Transaction control failed or was misused (commit without begin, nested misuse…).
UniqueConstraintViolationException (class)
Duplicate entry violates a unique constraint.
Omnitrix\Core\Database\Pool
ConnectionPool (class)
Bounded pool of physical connections for one worker process.
__construct(string $name, Omnitrix\Core\Database\Config\PoolConfig $config, Closure $factory, ?Closure $log = NULL)warmUp(): void— Opensminconnections eagerly and starts the eviction timer (call from the worker).acquire(?float $timeout = NULL, ?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): Omnitrix\Core\Database\Pool\PooledConnection— Leases a connection to the current coroutine.withConnection(callable $fn, ?float $timeout = NULL, ?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): mixed— Runs$fnwith a leased connection and releases it afterwards (also on exceptions).stats(): Omnitrix\Core\Database\Pool\PoolStatsisClosed(): boolevict(): int— Evicts idle connections past idle_timeout / max_lifetime, keepingmin.close(float $drainTimeout = 10.0): int— Graceful shutdown: refuses new leases, waits up to$drainTimeoutfor leased
PoolStats (class)
Snapshot of pool state for metrics and tests.
__construct(int $size, int $idle, int $inUse, int $waiting, int $created, int $destroyed, int $acquired, int $timeouts, int $validationFailures, float $totalWaitSeconds, float $maxWaitSeconds)toArray(): array
PooledConnection (class)
A connection checked out of the pool, bound to the coroutine that acquired it.
__construct(Omnitrix\Core\Database\Contracts\ConnectionInterface $inner, Omnitrix\Core\Database\Pool\ConnectionPool $pool, int $ownerCid)ownerCid(): intisReleased(): boolrelease(): void— Returns the connection to the pool (or discards it when broken / mid-transaction).inner(): Omnitrix\Core\Database\Contracts\ConnectionInterface— The underlying physical connection (for diagnostics; do not retain).id(): stringselect(string $sql, array $bindings = …): arrayexecute(string $sql, array $bindings = …): intinsert(string $sql, array $bindings = …): intbeginTransaction(): voidcommit(): voidrollBack(): voidinTransaction(): boolsetStatementTimeout(float $seconds): voidping(): boolisBroken(): boolmarkBroken(): voidcreatedAt(): floatlastUsedAt(): floattouch(): voidclose(): void— Closing a leased connection discards it from the pool.
Omnitrix\Core\Database\Query
Builder (class)
Fluent SQL builder with positional bindings. No hydration, no model layer: results are plain
__construct(Omnitrix\Core\Database\Contracts\GrammarInterface $grammar, Omnitrix\Core\Database\Query\QueryExecutorInterface $executor, ?string $table = NULL)static raw(string $sql, array $bindings = …): Omnitrix\Core\Database\Query\Expressionfrom(string $table): Omnitrix\Core\Database\Query\Builderselect(Omnitrix\Core\Database\Query\Expression|string ...$columns): Omnitrix\Core\Database\Query\BuilderaddSelect(Omnitrix\Core\Database\Query\Expression|string ...$columns): Omnitrix\Core\Database\Query\Builderdistinct(): Omnitrix\Core\Database\Query\Builderjoin(string $table, string $first, string $operator, string $second, string $type = 'inner'): Omnitrix\Core\Database\Query\BuilderleftJoin(string $table, string $first, string $operator, string $second): Omnitrix\Core\Database\Query\BuilderrightJoin(string $table, string $first, string $operator, string $second): Omnitrix\Core\Database\Query\Builderwhere(Omnitrix\Core\Database\Query\Expression|Closure|array|string $column, mixed $operator = NULL, mixed $value = NULL, string $boolean = 'and'): Omnitrix\Core\Database\Query\Builder—where('id', 10),where('age', '>=', 18),where(fn (Builder $q) => $q->where(...)->orWhere(...)),orWhere(Omnitrix\Core\Database\Query\Expression|Closure|array|string $column, mixed $operator = NULL, mixed $value = NULL): Omnitrix\Core\Database\Query\BuilderwhereIn(string $column, array $values, string $boolean = 'and', bool $not = false): Omnitrix\Core\Database\Query\BuilderwhereNotIn(string $column, array $values, string $boolean = 'and'): Omnitrix\Core\Database\Query\BuilderwhereNull(string $column, string $boolean = 'and', bool $not = false): Omnitrix\Core\Database\Query\BuilderwhereNotNull(string $column, string $boolean = 'and'): Omnitrix\Core\Database\Query\BuilderwhereBetween(string $column, mixed $from, mixed $to, string $boolean = 'and', bool $not = false): Omnitrix\Core\Database\Query\BuilderwhereColumn(string $first, string $operator, string $second, string $boolean = 'and'): Omnitrix\Core\Database\Query\BuilderwhereRaw(string $sql, array $bindings = …, string $boolean = 'and'): Omnitrix\Core\Database\Query\BuildergroupBy(string ...$columns): Omnitrix\Core\Database\Query\Builderhaving(Omnitrix\Core\Database\Query\Expression|string $column, string $operator, mixed $value, string $boolean = 'and'): Omnitrix\Core\Database\Query\BuilderorderBy(Omnitrix\Core\Database\Query\Expression|string $column, string $direction = 'asc'): Omnitrix\Core\Database\Query\BuilderorderByDesc(string $column): Omnitrix\Core\Database\Query\Builderlimit(int $limit): Omnitrix\Core\Database\Query\Builderoffset(int $offset): Omnitrix\Core\Database\Query\BuilderlockForUpdate(): Omnitrix\Core\Database\Query\BuildertoSql(): stringgetBindings(): arrayget(): arrayfirst(): ?arrayfind(string|int $id, string $column = 'id'): ?arrayvalue(string $column): mixedpluck(string $column): arraycount(string $column = '*'): intexists(): boolsum(string $column): int|floatmax(string $column): mixedmin(string $column): mixedavg(string $column): ?floatinsert(array $values): intinsertGetId(array $values): intupdate(array $values): intincrement(string $column, int|float $amount = 1, array $extra = …): intdecrement(string $column, int|float $amount = 1, array $extra = …): intdelete(): int
Expression (class)
A raw SQL fragment the builder inserts verbatim. Only ever build one from trusted,
__construct(string $sql, array $bindings = …)
QueryExecutorInterface (interface)
What the {@see Builder} needs to run compiled SQL (implemented by the connection manager).
select(string $sql, array $bindings = …): arrayexecute(string $sql, array $bindings = …): intinsert(string $sql, array $bindings = …): int
WhereClause (class)
One compiled-later WHERE condition.
__construct(string $type, string $boolean = 'and', string $column = '', string $operator = '', bool $not = false, int $count = 0, string $sql = '', ?Omnitrix\Core\Database\Query\Builder $nested = NULL, string $first = '', string $second = '')
Omnitrix\Core\Database\Transaction
TransactionManager (class)
Transactions with exclusive connection ownership.
__construct(string $connectionName)transaction(Omnitrix\Core\Database\Pool\ConnectionPool $pool, callable $callback, int $attempts = 1, ?float $acquireTimeout = NULL): mixedpinned(): ?Omnitrix\Core\Database\Pool\PooledConnection— The connection pinned by an enclosing transaction in the current coroutine, if any.
Omnitrix\Core\HttpClient\Exception
ConnectionException (class)
Could not connect, or the connection was reset/closed before a response arrived (refused, reset, server closed).
DnsException (class)
Hostname could not be resolved.
HttpClientException (class)
Base class of every outbound HTTP failure.
RequestException (class)
A 4xx/5xx response, raised by {@see Response::throw()}; the response is attached.
__construct(Omnitrix\Core\HttpClient\Response $response)
ResponseTooLargeException (class)
The response body exceeded max_response_size.
TimeoutException (class)
Connect or response timeout elapsed.
TlsException (class)
TLS handshake or certificate verification failed.
TooManyRedirectsException (class)
The redirect chain exceeded max_redirects.
Omnitrix\Core\HttpClient
HttpClient (class)
Outbound HTTP client: pooled connections, strict TLS, timeouts, redirect policy, bounded
__construct(Omnitrix\Core\HttpClient\HttpClientConfig $config, ?Omnitrix\Core\HttpClient\Transport\TransportInterface $transport = NULL)request(): Omnitrix\Core\HttpClient\PendingRequestget(string $url, array $query = …): Omnitrix\Core\HttpClient\Responsepost(string $url, ?array $json = NULL): Omnitrix\Core\HttpClient\Responsesend(string $method, Omnitrix\Core\HttpClient\Uri $uri, array $headers, string $body, Omnitrix\Core\HttpClient\RequestOptions $options, ?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): Omnitrix\Core\HttpClient\Response— Executes a prepared request: redirects, retries, size limit and in-flight cap.stats(): arrayclose(): void
HttpClientConfig (class)
Validated http_client configuration section (defaults for every outbound request).
static fromArray(array $config): Omnitrix\Core\HttpClient\HttpClientConfigstatic defaults(): Omnitrix\Core\HttpClient\HttpClientConfig
PendingRequest (class)
Fluent request builder.
__construct(Omnitrix\Core\HttpClient\HttpClient $client)withHeaders(array $headers): Omnitrix\Core\HttpClient\PendingRequestwithHeader(string $name, string $value): Omnitrix\Core\HttpClient\PendingRequestwithToken(string $token, string $type = 'Bearer'): Omnitrix\Core\HttpClient\PendingRequestwithBasicAuth(string $username, string $password): Omnitrix\Core\HttpClient\PendingRequestaccept(string $contentType): Omnitrix\Core\HttpClient\PendingRequestwithQuery(array $query): Omnitrix\Core\HttpClient\PendingRequestasJson(mixed $data): Omnitrix\Core\HttpClient\PendingRequest— JSON body (objects/arrays/JsonSerializable).asForm(array $fields): Omnitrix\Core\HttpClient\PendingRequest— application/x-www-form-urlencoded body.withBody(string $body, string $contentType): Omnitrix\Core\HttpClient\PendingRequest— Raw body with an explicit content type.timeout(float $seconds): Omnitrix\Core\HttpClient\PendingRequest— Response timeout in seconds (after the request was sent).connectTimeout(float $seconds): Omnitrix\Core\HttpClient\PendingRequestmaxRedirects(int $count): Omnitrix\Core\HttpClient\PendingRequestwithoutRedirecting(): Omnitrix\Core\HttpClient\PendingRequestmaxResponseSize(int $bytes): Omnitrix\Core\HttpClient\PendingRequestwithCaFile(string $path): Omnitrix\Core\HttpClient\PendingRequest— Pins a CA bundle for this request (private PKI).withoutTlsVerification(): Omnitrix\Core\HttpClient\PendingRequest— Disables certificate verification for this request only. Never use against productionretry(int $times, bool $onTimeout = false): Omnitrix\Core\HttpClient\PendingRequest— Retries (idempotent methods only) on connection failures.http2(bool $enabled = true): Omnitrix\Core\HttpClient\PendingRequestwithCancellation(Omnitrix\Core\Concurrency\CancellationToken $token): Omnitrix\Core\HttpClient\PendingRequestget(string $url): Omnitrix\Core\HttpClient\Responsehead(string $url): Omnitrix\Core\HttpClient\Responsepost(string $url): Omnitrix\Core\HttpClient\Responseput(string $url): Omnitrix\Core\HttpClient\Responsepatch(string $url): Omnitrix\Core\HttpClient\Responsedelete(string $url): Omnitrix\Core\HttpClient\Responsesend(string $method, string $url): Omnitrix\Core\HttpClient\Responsedownload(string $url, string $path): Omnitrix\Core\HttpClient\Response— Streams the response body into$path(not buffered; size limit does not apply).
RequestOptions (class)
Per-request overrides of {@see HttpClientConfig} (null = use the configured default).
__construct(?float $timeout = NULL, ?float $connectTimeout = NULL, ?int $maxRedirects = NULL, ?int $maxResponseSize = NULL, ?bool $verifyTls = NULL, ?string $caFile = NULL, ?int $retries = NULL, ?bool $retryOnTimeout = NULL, ?bool $http2 = NULL, ?string $downloadTo = NULL)
Response (class)
An outbound HTTP response (fully buffered body).
__construct(int $status, array $headers, string $body, string $url, array $setCookies = …, int $redirects = 0, float $elapsed = 0.0, string $protocol = '1.1')status(): intok(): boolsuccessful(): boolredirect(): boolclientError(): boolserverError(): boolfailed(): boolthrow(): Omnitrix\Core\HttpClient\Response— Throws {@see RequestException} for 4xx/5xx; returns $this otherwise.header(string $name, ?string $default = NULL): ?stringhasHeader(string $name): boolheaders(): arraysetCookies(): arraycontentType(): ?stringbody(): stringsize(): intjson(): mixed— Decoded JSON body (objects as arrays), decoded once and cached.jsonObject(): array— JSON object body as a string-keyed array.url(): string— Final URL after redirects.redirectCount(): intelapsed(): float— Wall-clock seconds for the whole exchange including redirects and retries.protocol(): string
Omnitrix\Core\HttpClient\Transport
CancelledOutboundException (class)
The coroutine performing the request was cancelled (timeout group, request abort).
Exchange (class)
One request as handed to a transport (after defaults, auth, query and body were applied).
__construct(string $method, Omnitrix\Core\HttpClient\Uri $uri, array $headers, string $body, float $connectTimeout, float $timeout, bool $verifyTls, ?string $caFile, bool $http2, ?string $downloadTo = NULL)
OpenSwooleTransport (class)
Pooled OpenSwoole coroutine HTTP transport.
__construct(Omnitrix\Core\HttpClient\HttpClientConfig $config)exchange(Omnitrix\Core\HttpClient\Transport\Exchange $exchange, ?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): Omnitrix\Core\HttpClient\Transport\RawResponsestats(): arrayclose(): void
RawResponse (class)
What a transport returns for one exchange.
__construct(int $status, array $headers, string $body, array $setCookies = …, string $protocol = '1.1')
TransportInterface (interface)
Performs exactly one HTTP exchange. Transports throw the HttpClient exception hierarchy for
exchange(Omnitrix\Core\HttpClient\Transport\Exchange $exchange, ?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): Omnitrix\Core\HttpClient\Transport\RawResponsestats(): arrayclose(): void
Omnitrix\Core\HttpClient
Uri (class)
Parsed absolute http(s) URL with helpers for query merging and redirect resolution.
static parse(string $url): Omnitrix\Core\HttpClient\UriisTls(): booltarget(): string— Request target (path + query) as sent on the wire.hostHeader(): stringorigin(): string— Origin key used for connection pooling.withQuery(array $params): Omnitrix\Core\HttpClient\Uriresolve(string $location): Omnitrix\Core\HttpClient\Uri— Resolves a Location header against this URL (absolute, protocol-relative, absolute-path or relative).
Omnitrix\Core\Http
HttpErrorInterface (interface)
An error that maps directly to an HTTP response.
status(): intheaders(): arraydetails(): array
Omnitrix\Core\Http\Server
HeadersAlreadySentException (class)
Status, headers or cookies were modified after the response started streaming.
HttpServerAdapter (class)
Bridges the runtime entry point to the HTTP transport layer.
__construct(Omnitrix\Core\Http\Server\HttpServerConfig $config, callable $handler, Omnitrix\Core\Runtime\Exception\ExceptionHandlerInterface $exceptionHandler)__invoke(OpenSwoole\Http\Request $raw, OpenSwoole\Http\Response $rawResponse, Omnitrix\Core\Runtime\Context\RequestContext $context): void
HttpServerConfig (class)
Validated http configuration section (transport-level policies of the HTTP adapter).
static fromArray(array $config, int $packageMaxLength = 2097152): Omnitrix\Core\Http\Server\HttpServerConfigstatic defaults(): Omnitrix\Core\Http\Server\HttpServerConfig
IncomingRequest (class)
Transport-level view of an HTTP request parsed by OpenSwoole.
__construct(OpenSwoole\Http\Request $raw, int $jsonMaxDepth = 64)raw(): OpenSwoole\Http\Requestmethod(): string— Upper-case HTTP method.isMethod(string $method): boolpath(): string— Path without query string, as sent (not decoded, not normalised).queryString(): stringquery(): array— Parsed query parameters (PHP array syntax supported).queryParam(string $name, mixed $default = NULL): mixedprotocolVersion(): string— HTTP protocol version such as "1.1" or "2".headers(): arrayheader(string $name, ?string $default = NULL): ?stringhasHeader(string $name): boolcookies(): arraycookie(string $name, ?string $default = NULL): ?stringcontentType(): ?string— Media type of the body without parameters, lower-case (e.g. "application/json"), or null.isJson(): booldeclaredContentLength(): ?int— Declared Content-Length, or null when absent/invalid.body(): string— Raw request body (empty string when none).bodyLength(): intjson(): mixed— Decoded JSON body (objects as associative arrays). Decoded once; an empty body decodes tojsonObject(): array— JSON body that must be an object (associative array).form(): array— Parsed form fields for application/x-www-form-urlencoded and multipart bodies.files(): array— Uploaded files as parsed by OpenSwoole.remoteAddress(): ?stringremotePort(): ?intreceivedAt(): float— Server-side receive time (float unix timestamp).connectionId(): int— OpenSwoole connection descriptor.
OpenSwooleResponseSink (class)
{@see ResponseSinkInterface} over the live OpenSwoole response.
__construct(OpenSwoole\Http\Response $response)status(int $code, string $reason): voidheader(string $name, string $value): voidcookie(string $name, string $value, int $expires, string $path, string $domain, bool $secure, bool $httpOnly, string $sameSite): voidwrite(string $chunk): boolend(string $body): boolsendFile(string $path, int $offset, int $length): bool
RequestRejectedException (class)
The transport rejected a request before it reached application code (malformed body, size limit).
__construct(int $status, string $message, array $headers = …, array $details = …, ?Throwable $previous = NULL)static badRequest(string $message, ?Throwable $previous = NULL): Omnitrix\Core\Http\Server\RequestRejectedExceptionstatic payloadTooLarge(int $limit): Omnitrix\Core\Http\Server\RequestRejectedExceptionstatus(): intheaders(): arraydetails(): array
ResponseSinkInterface (interface)
The transport the {@see ResponseWriter} writes to. The OpenSwoole implementation wraps
status(int $code, string $reason): voidheader(string $name, string $value): voidcookie(string $name, string $value, int $expires, string $path, string $domain, bool $secure, bool $httpOnly, string $sameSite): voidwrite(string $chunk): bool— Sends a chunk (chunked transfer encoding). Returns false when the client is gone.end(string $body): bool— Sends the final (or only) body and completes the response.sendFile(string $path, int $offset, int $length): bool— Sends a file via sendfile(2); completes the response.
ResponseWriter (class)
Builds and sends one HTTP response.
__construct(Omnitrix\Core\Http\Server\ResponseSinkInterface $sink, bool $headOnly = false, int $jsonFlags = 320)status(int $code): Omnitrix\Core\Http\Server\ResponseWriterstatusCode(): intheader(string $name, string $value): Omnitrix\Core\Http\Server\ResponseWriterheaders(array $headers): Omnitrix\Core\Http\Server\ResponseWriterremoveHeader(string $name): Omnitrix\Core\Http\Server\ResponseWriterhasHeader(string $name): boolgetHeader(string $name): ?stringgetHeaders(): arraycookie(string $name, string $value, int $expires = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httpOnly = true, string $sameSite = 'Lax'): Omnitrix\Core\Http\Server\ResponseWriterwrite(string $chunk): bool— Streams a chunk. The first call commits status and headers.end(string $body = ''): bool— Sends the final body (or an empty body) and ends the response.json(mixed $data, int $status = 200): bool— Ends with a JSON body.text(string $body, int $status = 200, string $contentType = 'text/plain; charset=utf-8'): boolnoContent(): boolredirect(string $location, int $status = 302): boolsendFile(string $path, int $offset = 0, int $length = 0): bool— Sends a file with sendfile(2).$length0 means "to the end of the file".isEnded(): boolheadersSent(): boolclientGone(): bool— True once the transport reported that the client disconnected.bytesWritten(): int
Omnitrix\Core\Http
Status (class)
HTTP status codes and reason phrases used by the framework.
static phrase(int $code): stringstatic isValid(int $code): boolstatic isError(int $code): bool
Omnitrix\Core\IO
ConnectionClosedException (class)
The peer closed the connection before the expected data arrived.
Dns (class)
Coroutine DNS resolution (c-ares via Coroutine\System) with a small per-worker TTL cache.
__construct(float $ttl = 60.0, int $maxEntries = 1024)resolve(string $host, float $timeout = 5.0): stringresolveAll(string $host, float $timeout = 5.0): arrayclear(): void
Filesystem (class)
Filesystem helpers that do not block the event loop.
read(string $path): stringwrite(string $path, string $data): void— Atomic write: data goes to a sibling temp file which is then renamed over the target.append(string $path, string $data): voidexists(string $path): booldelete(string $path): boolensureDirectory(string $path, int $mode = 509): voiddeleteDirectory(string $path): void— Removes a directory tree.readChunks(string $path, int $chunkSize = 65536): Generator— Streams a file in chunks without loading it into memory.writeChunks(string $path, iterable $chunks): int— Writes chunks from any iterable to$path(streaming copy); returns bytes written.
IoException (class)
Base class of socket, DNS and filesystem errors.
IoTimeoutException (class)
A socket operation did not complete within its timeout.
TcpConnection (class)
A connected TCP stream on an OpenSwoole coroutine socket. Every wait suspends only the
__construct(OpenSwoole\Coroutine\Socket $socket)static connect(string $host, int $port, float $timeout = 5.0, ?Omnitrix\Core\IO\Dns $dns = NULL): Omnitrix\Core\IO\TcpConnectionsend(string $data, float $timeout = 5.0): void— Sends all bytes.receive(int $maxBytes = 65536, float $timeout = 5.0): string— Up to$maxBytesbytes as soon as any arrive; '' when the peer closed.receiveExactly(int $bytes, float $timeout = 5.0): string— Exactly$bytesbytes, or an exception.receiveLine(int $maxBytes = 65536, float $timeout = 5.0): string— One line including the trailing "\n" (max$maxBytes); '' when the peer closed.remote(): ?arrayclose(): voidisClosed(): bool
TcpServer (class)
Coroutine TCP server for auxiliary listeners inside a worker or standalone coroutine program
__construct(string $host, int $port, Omnitrix\Core\Runtime\Exception\ExceptionHandlerInterface $exceptionHandler, int $maxConnections = 1024, int $backlog = 512)port(): int— The bound port (useful with port 0).serve(callable $handler): void— Accept loop; returns after {@see stop()}. Run it in its own coroutine.isRunning(): boolstop(): void— Stops accepting (the loop exits within 0.5 s) and closes the listener.close(): voidaccepted(): intactiveConnections(): int
TempFiles (class)
Temporary files with guaranteed cleanup. Files are created with unpredictable names
__construct(?string $directory = NULL, Omnitrix\Core\IO\Filesystem $filesystem = …)create(string $prefix = 'omnitrix-', string $suffix = '.tmp'): stringforRequest(Omnitrix\Core\Runtime\Context\RequestContext $context, string $prefix = 'omnitrix-', string $suffix = '.tmp'): string— Creates a temp file removed automatically when$contextis disposed.remove(string $path): voidcleanup(): intcount(): int
UdpSocket (class)
Coroutine UDP socket (datagrams; no delivery guarantee).
__construct(string $bindHost = '0.0.0.0', int $bindPort = 0)port(): intsendTo(string $address, int $port, string $data): voidreceive(float $timeout = 5.0): array— Waits for one datagram.close(): void
Omnitrix\Core\Log
JsonLogger (class)
Minimal structured (one JSON object per line) PSR-3 logger writing to a stream.
__construct($stream = NULL, array $redactKeys = …, bool $includeTraces = false, string $channel = 'omnitrix', string $minimumLevel = 'debug')log($level, Stringable|string $message, array $context = …): void
Omnitrix\Core\Observability
MetricsRegistry (class)
Request metrics in OpenSwoole shared memory: every worker records into the same table (create
__construct(int $maxSeries = 4096)observe(string $route, string $method, int $status, float $seconds): voidseries(): arrayrender(array $gauges = …): string— Prometheus text exposition (v0.0.4).maxSeen(): int
Omnitrix\Core\Pool
ClientPool (class)
Bounded pool of reusable client objects (HTTP connections, Redis clients…) for one worker.
__construct(string $key, int $max, float $acquireTimeout, float $idleTimeout, Closure $factory, Closure $destroyer, ?Closure $validator = NULL, float $validationInterval = 0.0)acquire(?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): objectrelease(object $client, bool $healthy = true): voidevict(): int— Closes idle clients unused for longer than the idle timeout.close(): voidstats(): array
PoolTimeoutException (class)
No pooled client became available within the acquisition timeout (backpressure signal).
Omnitrix\Core\Process
CpuException (class)
Base class of CPU pool errors.
CpuJobException (class)
The job threw inside the worker process; the worker survives. Carries the remote class name.
__construct(string $message, string $remoteClass)
CpuPool (class)
Client side of the CPU pool, used from HTTP workers (or any coroutine).
__construct(Omnitrix\Core\Process\CpuPoolConfig $config, Omnitrix\Core\Process\CpuLoadBoard $board)run(string $job, array $args = …, ?float $timeout = NULL): mixed— Runs a registered job with JSON-compatible arguments and returns its JSON-compatible result.stats(): array
CpuPoolConfig (class)
CPU pool settings.
__construct(int $workers = 2, float $timeout = 30.0, int $maxPending = 64, string $socketDirectory = '', string $name = 'default')socketPath(int $index): string
CpuTimeoutException (class)
The job did not finish in time; if it had started, its worker process was killed and is restarted.
WorkerCrashedException (class)
The worker process died while running the job (fatal error, OOM, signal). It is restarted.
Omnitrix\Core\Queue
Job (class)
An immutable queued job. The JSON form is what lives in Redis.
__construct(string $id, string $name, array $payload, string $queue = 'default', int $attempts = 0, int $maxAttempts = 3, float $createdAt = 0.0, ?string $lastError = NULL)static create(string $name, array $payload, string $queue = 'default', int $maxAttempts = 3): Omnitrix\Core\Queue\JobwithAttempt(?string $error): Omnitrix\Core\Queue\JobhasAttemptsLeft(): booltoJson(): stringstatic fromJson(string $json): Omnitrix\Core\Queue\Job
QueueConsumer (class)
Processes jobs from one queue with $concurrency coroutines in a long-running consumer
__construct(Omnitrix\Core\Queue\RedisQueue $queue, array $handlers, string $queueName = 'default', int $concurrency = 4, float $jobTimeout = 60.0, float $backoffBase = 1.0, float $backoffMax = 300.0, Psr\Log\LoggerInterface $logger = …, ?string $consumerId = NULL)run(): void— Blocks until stop() was called and in-flight jobs finished. Run inside a coroutine.stop(): voidisRunning(): boolstats(): arrayhandlerCount(): int
QueueException (class)
QueueProducer (class)
Producer side of the queue, used by request handlers (one per worker).
__construct(Omnitrix\Core\Queue\RedisQueue $queue, string $defaultQueue = 'default', int $defaultMaxAttempts = 3)dispatch(string $name, array $payload = …, float $delay = 0.0, ?string $queue = NULL, ?int $maxAttempts = NULL): string— Enqueues$namewith a JSON-compatible payload; returns the job id.stats(?string $queue = NULL): array
RedisQueue (class)
Reliable queue on Redis lists.
__construct(Omnitrix\Core\Redis\RedisClient $redis)push(Omnitrix\Core\Queue\Job $job, float $delay = 0.0): void— Enqueues a job, optionally delayed by$delayseconds.reserve(string $queue, string $consumer, int $timeout = 1): ?array— Waits up to$timeoutseconds (whole seconds, ≥ 1) for a job and moves it to theack(string $queue, string $consumer, string $raw): void— Removes a finished job from the processing list.retry(string $queue, string $consumer, string $raw, Omnitrix\Core\Queue\Job $next, float $delay): void— Re-schedules a failed job after$delayseconds (atomic move).bury(string $queue, string $consumer, string $raw, Omnitrix\Core\Queue\Job $final): void— Moves a job that exhausted its attempts to the dead letter list (atomic).heartbeat(string $consumer, int $ttl): void— Marks a consumer alive for$ttlseconds.forgetConsumer(string $consumer): voidrecover(string $queue): int— Returns jobs held by consumers whose heartbeat expired (crashed or killed) toready.stats(string $queue): arraydeadLetters(string $queue, int $limit = 100): arraypromoteDue(string $queue): int— Moves due delayed jobs toready(atomic Lua script).purge(string $queue): void— Deletes every key of a queue (tests / administration).static key(string $queue, string $suffix): string
Omnitrix\Core\Redis
ErrorClassifier (class)
Maps phpredis exceptions (message-based; phpredis has no error codes) to typed exceptions.
static classify(Throwable $e, string $context = ''): Omnitrix\Core\Redis\Exception\RedisException
Omnitrix\Core\Redis\Exception
CommandException (class)
The server rejected a command (WRONGTYPE, syntax, NOAUTH…); the connection stays usable.
ConnectionException (class)
Connect/auth failure, lost connection or read timeout; the pooled connection is discarded.
RedisException (class)
Base class of Redis errors raised by Omnitrix.
TimeoutException (class)
A read timed out (blocking command or slow server); the connection is discarded.
Omnitrix\Core\Redis
RedisClient (class)
Coroutine-safe Redis access: every command leases a pooled connection for its duration.
__construct(Omnitrix\Core\Redis\RedisConfig $config, ?Omnitrix\Core\Redis\RedisPool $pool = NULL)pool(): Omnitrix\Core\Redis\RedisPoolwithConnection(callable $fn, ?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): mixed— Runs$fnwith a leased connection. Connection-class failures discard the connection.command(string $name, array $args = …): mixed— Any command by name ($redis->rawCommand), for commands without a typed helper.get(string $key): ?stringset(string $key, string $value, ?int $ttl = NULL): boolsetIfAbsent(string $key, string $value, ?int $ttl = NULL): bool— SET NX (returns false when the key exists).mget(array $keys): arraydelete(string ...$keys): intexists(string $key): boolexpire(string $key, int $seconds): boolttl(string $key): int— Remaining TTL in seconds, -1 without expiry, -2 when missing.increment(string $key, int $by = 1): intdecrement(string $key, int $by = 1): inthget(string $key, string $field): ?stringhset(string $key, string $field, string $value): voidhgetall(string $key): arraylpush(string $key, string ...$values): intrpush(string $key, string ...$values): intlpop(string $key): ?stringllen(string $key): intblpop(array $keys, int $timeout): ?array— Blocking pop (BLPOP) bounded by$timeoutseconds; null when nothing arrived. The pooledsadd(string $key, string ...$members): intsmembers(string $key): arraypipeline(callable $commands): array— Queues commands on one connection and sends them in one round trip.transaction(callable $commands): array— MULTI/EXEC transaction (atomic on the server).publish(string $channel, string $message): intsubscribe(array $channels, callable $handler, ?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): void— Subscribes on a dedicated connection and delivers messages to$handleruntil it returnsping(): boolstats(): arrayclose(): voidgetMany(array $keys): arraythrowIfUnavailable(): void
RedisConfig (class)
Validated redis configuration section.
static fromArray(array $config): Omnitrix\Core\Redis\RedisConfig
RedisPool (class)
Pool of phpredis connections for one worker. Each connection is used by one coroutine at a
__construct(Omnitrix\Core\Redis\RedisConfig $config)connect(): Redis— Opens a fresh, authenticated connection outside the pool (pub/sub, blocking consumers).acquire(?Omnitrix\Core\Concurrency\CancellationToken $token = NULL): Redisrelease(Redis $redis, bool $healthy = true): voidstats(): arrayclose(): void
Omnitrix\Core\Runtime\Config
InvalidConfigurationException (class)
A configuration value is missing, has the wrong type or is out of range.
static at(string $path, string $problem): Omnitrix\Core\Runtime\Config\InvalidConfigurationException
RuntimeConfig (class)
Validated, immutable runtime/server configuration.
static fromArray(array $config): Omnitrix\Core\Runtime\Config\RuntimeConfigtoOpenSwooleSettings(): array— The OpenSwooleServer::set()array. Explicit options win overextraOptions.
ServerMode (enum)
OpenSwoole process model.
openSwooleMode(): intstatic cases(): arraystatic from(string|int $value): staticstatic tryFrom(string|int $value): ?static
Omnitrix\Core\Runtime\Context
ContextNotAvailableException (class)
Raised when request-scoped state is accessed outside of a request coroutine (or its children).
ContextStorage (class)
Coroutine-local storage for the current {@see RequestContext}.
static bind(Omnitrix\Core\Runtime\Context\RequestContext $context): void— Binds a context to the current coroutine.static unbind(): void— Removes the binding from the current coroutine (does not dispose the context).static current(): ?Omnitrix\Core\Runtime\Context\RequestContext— The context bound to this coroutine or inherited from an ancestor, or null.static require(): Omnitrix\Core\Runtime\Context\RequestContext
RequestContext (class)
Per-request state container.
__construct(string $id)static create(): Omnitrix\Core\Runtime\Context\RequestContextelapsed(): float— Seconds elapsed since the context was created.set(string $key, mixed $value): voidget(string $key, mixed $default = NULL): mixedhas(string $key): boolremove(string $key): voidall(): arraysetDeadline(float $unixTimestamp): void— Absolute deadline as a unix timestamp (float seconds). Consumers (pools, clients) readdeadline(): ?floatremainingTime(): ?float— Seconds until the deadline (may be negative once expired), or null when no deadline.isExpired(): booldefer(callable $callback): void— Registers a callback executed when the request ends. Callbacks run in reverseisDisposed(): booldispose(): array— Runs deferred callbacks (LIFO) and clears attributes. Idempotent.
Omnitrix\Core\Runtime\Coroutine
Coroutines (class)
Guarded coroutine creation.
static spawn(callable $body, Omnitrix\Core\Runtime\Exception\ExceptionHandlerInterface $handler, array $context = …): int
Sleep (class)
Cooperative sleep with sub-second resolution.
static for(float $seconds): voidstatic milliseconds(int $ms): void
Timers (class)
Thin, typed wrapper around OpenSwoole timers.
static after(int $ms, callable $callback): ?int— Schedules$callbackonce after$msmilliseconds; returns the timer id or null.static tick(int $ms, callable $callback): ?int— Schedules$callbackevery$msmilliseconds; returns the timer id or null.static clear(int $timerId): boolstatic exists(int $timerId): boolstatic clearAll(): void
Omnitrix\Core\Runtime\Exception
ErrorHandler (class)
Converts PHP warnings/notices/deprecations into {@see ErrorException}s so they surface
register(): voidunregister(): voidisRegistered(): bool
ExceptionHandlerInterface (interface)
Receives every exception the runtime catches at a coroutine boundary (request handlers,
handle(Throwable $exception, array $context = …): void
LoggingExceptionHandler (class)
Logs exceptions at error level with the originating context. If the logger itself fails,
__construct(Psr\Log\LoggerInterface $logger)handle(Throwable $exception, array $context = …): void
Omnitrix\Core\Runtime\Lifecycle
LifecycleState (enum)
static cases(): arraystatic from(string|int $value): staticstatic tryFrom(string|int $value): ?static
ServerRuntime (class)
Application lifecycle root: Created → Built → Running → Stopped.
static create(array $config, ?Psr\Log\LoggerInterface $logger = NULL, ?Omnitrix\Core\Runtime\Exception\ExceptionHandlerInterface $exceptionHandler = NULL): Omnitrix\Core\Runtime\Lifecycle\ServerRuntimestate(): Omnitrix\Core\Runtime\Lifecycle\LifecycleStateconfig(): arrayruntimeConfig(): Omnitrix\Core\Runtime\Config\RuntimeConfiglogger(): Psr\Log\LoggerInterfaceexceptionHandler(): Omnitrix\Core\Runtime\Exception\ExceptionHandlerInterfaceworkerLifecycle(): Omnitrix\Core\Runtime\Worker\WorkerLifecycleonWorkerStart(callable $listener): Omnitrix\Core\Runtime\Lifecycle\ServerRuntimeonWorkerStop(callable $listener): Omnitrix\Core\Runtime\Lifecycle\ServerRuntimeconfigureContainer(callable $configurator): Omnitrix\Core\Runtime\Lifecycle\ServerRuntime— Registers services in each worker's container before start listeners run.handle(callable $handler): Omnitrix\Core\Runtime\Lifecycle\ServerRuntimeonTask(callable $handler): Omnitrix\Core\Runtime\Lifecycle\ServerRuntimeonBuild(callable $hook): Omnitrix\Core\Runtime\Lifecycle\ServerRuntime— Runs after the server object is created and before it starts (master process); used tobuild(): OpenSwoole\Http\Server— Builds the server without starting it (useful for inspection and tests).run(): void— Builds (if needed) and starts the server. Blocks until the server shuts down.server(): ?OpenSwoole\Http\Serverstop(): void— Requests a graceful shutdown (from any worker or the master).reload(): void— Gracefully restarts all workers.
Omnitrix\Core\Runtime\Scheduler
BoundedScheduler (class)
Admits at most $limit concurrently running coroutines (backpressure for application-level
__construct(int $limit, float $acquireTimeout, Omnitrix\Core\Runtime\Exception\ExceptionHandlerInterface $exceptionHandler)spawn(callable $task, ?callable $onComplete = NULL, ?float $acquireTimeout = NULL): int— Starts$taskin a new coroutine once a slot is free. Returns the coroutine id.run(callable $task, ?float $acquireTimeout = NULL): mixed— Runs$taskinline in the current coroutine while holding a slot.running(): intavailable(): intstats(): array
SchedulerSaturatedException (class)
The bounded scheduler could not admit a task within the acquisition timeout.
Omnitrix\Core\Runtime\Shutdown
ResourceRegistry (class)
Tracks worker-scoped resources (pools, sockets, timers, temp files) and releases them in a
register(string $name, callable $closer, int $priority = 0): voidhas(string $name): boolforget(string $name): void— Removes a resource without closing it (the owner released it already).names(): arraycount(): intreleaseAll(): array— Releases everything. Idempotent and re-entrancy safe.
SignalHandler (class)
Signal handling for standalone coroutine runtimes (queue consumers, CPU pools, tooling).
onTerminate(callable $onSignal, array $signals = …): voidrelease(): voidinstalledSignals(): array
Omnitrix\Core\Runtime\Worker
WorkerContext (class)
Everything a worker-scoped service may need at start-up: identity, the worker container,
__construct(int $workerId, int $pid, Omnitrix\Core\Runtime\Worker\WorkerRole $role, Omnitrix\Core\Container\Container $container, Omnitrix\Core\Runtime\Shutdown\ResourceRegistry $resources, ?OpenSwoole\Server $server)
WorkerRole (enum)
static cases(): arraystatic from(string|int $value): staticstatic tryFrom(string|int $value): ?static
Omnitrix\Core\Support
Id (class)
Opaque identifiers (request ids, task ids). Cryptographically random, URL-safe hex.
static generate(): string— 32 hex characters (128 bits).
Platform (class)
Read-only facts about the runtime the framework is executing on.
static phpVersion(): stringstatic hasOpenSwoole(): boolstatic openSwooleVersion(): ?stringstatic kernelVersion(): ?string— Kernel release string such as "4.14.190" (Linux) or null when not determinable.static supportsIoUring(): bool— Whether the io_uring reactor can be requested safely: the extension exposes thestatic inCoroutine(): boolstatic assertSupported(): void
RuntimeRequirementException (class)
Thrown when the process does not satisfy a hard runtime requirement of the framework
Omnitrix\Database
Collection (class)
An ordered list of models returned by queries. Serialises to a JSON array.
__construct(iterable $items = …)all(): arrayfirst(): ?Omnitrix\Database\Modellast(): ?Omnitrix\Database\ModelisEmpty(): boolisNotEmpty(): boolcount(): intmap(callable $callback): arrayfilter(callable $callback): Omnitrix\Database\Collectioneach(callable $callback): voidpluck(string $attribute): arraykeyBy(string $attribute): arraymodelKeys(): arrayload(array|string ...$relations): Omnitrix\Database\Collection— Eager loads relations for every model in the collection with one query per relation.toArray(): arrayjsonSerialize(): arraygetIterator(): TraversableoffsetExists(mixed $offset): booloffsetGet(mixed $offset): ?Omnitrix\Database\ModeloffsetSet(mixed $offset, mixed $value): voidoffsetUnset(mixed $offset): void
DatabaseCreator (class)
Creates the database named in the database configuration when it does not exist yet. Used by
__construct(array $section, ?string $connection = NULL)static isUnknownDatabase(Throwable $error): bool— True when$error(or one of its previous exceptions) is MySQL's "Unknown database".name(): stringcreate(): void— Creates the database (if it does not exist) with the configured charset and collation.
Omnitrix\Database\Migrations
Migration (abstract class)
A schema change. Migration files in database/migrations/ return an instance:
up(Omnitrix\Database\Schema\Schema $schema): voiddown(Omnitrix\Database\Schema\Schema $schema): void
Migrator (class)
Runs migration files in filename order and records each one, with a batch number, in the
__construct(Omnitrix\Core\Database\DatabaseManager $databases, string $path, ?callable $listener = NULL)migrate(): array— Runs every pending migration in one new batch.rollback(int $steps = 1): array— Reverts the last$stepsbatches (most recent first).reset(): array— Reverts every migration that ran.fresh(): array— Drops every table of the default connection, then runs all migrations.status(): arrayfiles(): arrayran(): arrayensureRepository(): void
Omnitrix\Database
Model (abstract class)
A database row as an object, with relationships.
__construct(array $attributes = …)static query(): Omnitrix\Database\ModelQuerystatic all(): Omnitrix\Database\Collectionstatic find(string|int $id): ?staticstatic findOrFail(string|int $id): staticstatic create(array $attributes): staticstatic with(array|string ...$relations): Omnitrix\Database\ModelQuerystatic where(Omnitrix\Core\Database\Query\Expression|Closure|array|string $column, mixed $operator = NULL, mixed $value = NULL): Omnitrix\Database\ModelQuerystatic table(): stringstatic keyName(): stringstatic foreignKeyName(): string— Foreign key other tables use to reference this model:User→user_id.static connection(): Omnitrix\Core\Database\Databasestatic usesTimestamps(): boolfill(array $attributes): static— Sets fillable attributes; keys not listed in$fillableare ignored.forceFill(array $attributes): static— Sets attributes without the$fillablecheck. Use only with trusted input.getAttribute(string $key): mixedsetAttribute(string $key, mixed $value): voidgetKey(): string|int|nullexists(): boolgetAttributes(): arraygetDirty(): arrayisDirty(?string $attribute = NULL): boolsave(): bool— Inserts the model, or updates the changed attributes of an existing one.update(array $attributes): bool— Fills and saves in one step.delete(): boolrefresh(): static— Reloads the attributes from the database and forgets loaded relations.load(array|string ...$relations): static— Eager loads relations on this model (see {@see ModelQuery::with()}).setRelation(string $name, Omnitrix\Database\Model|Omnitrix\Database\Collection|null $value): voidrelationLoaded(string $name): boolgetRelation(string $name): Omnitrix\Database\Model|Omnitrix\Database\Collection|nulltoArray(): arrayjsonSerialize(): arrayoffsetExists(mixed $offset): booloffsetGet(mixed $offset): mixedoffsetSet(mixed $offset, mixed $value): voidoffsetUnset(mixed $offset): void
ModelNotFoundException (class)
No row matched findOrFail() / firstOrFail(). Answered as 404 when it reaches the kernel.
__construct(string $model, array $ids = …)
ModelQuery (class)
Query builder that returns models. Every filter, ordering and aggregate of the database
__construct(string $model, Omnitrix\Core\Database\Query\Builder $builder)with(array|string ...$relations): Omnitrix\Database\ModelQuery— Eager loads relations with the results:with('author'), nestedwith('posts.comments'),where(Omnitrix\Core\Database\Query\Expression|Closure|array|string $column, mixed $operator = NULL, mixed $value = NULL): Omnitrix\Database\ModelQuerywhereIn(string $column, array $values): Omnitrix\Database\ModelQuerywhereNull(string $column): Omnitrix\Database\ModelQueryselect(Omnitrix\Core\Database\Query\Expression|string ...$columns): Omnitrix\Database\ModelQueryorderBy(string $column, string $direction = 'asc'): Omnitrix\Database\ModelQueryorderByDesc(string $column): Omnitrix\Database\ModelQuerylatest(string $column = 'created_at'): Omnitrix\Database\ModelQuery— Newest first bycreated_at(or another column).oldest(string $column = 'created_at'): Omnitrix\Database\ModelQuery— Oldest first bycreated_at(or another column).limit(int $limit): Omnitrix\Database\ModelQueryoffset(int $offset): Omnitrix\Database\ModelQueryget(): Omnitrix\Database\Collectionfirst(): ?Omnitrix\Database\ModelfirstOrFail(): Omnitrix\Database\Modelfind(string|int $id): ?Omnitrix\Database\ModelfindOrFail(string|int $id): Omnitrix\Database\ModelfindMany(array $ids): Omnitrix\Database\Collectionpaginate(int $perPage = 15, int $page = 1): Omnitrix\Database\Paginator— Counts the matching rows, then loads one page (pages start at 1).create(array $attributes): Omnitrix\Database\Model— Creates and saves a model.update(array $values): int— Updates every matching row without loading models.delete(): int— Deletes every matching row without loading models.toBase(): Omnitrix\Core\Database\Query\Builder— The underlying database query builder.modelClass(): stringqualify(string $column): string
Paginator (class)
One page of models with totals. Serialises to
__construct(Omnitrix\Database\Collection $items, int $total, int $perPage, int $currentPage)hasMorePages(): booltoArray(): arrayjsonSerialize(): array
Omnitrix\Database\Relations
BelongsTo (class)
posts.user_id → users.id: a post belongs to its author.
__construct(Omnitrix\Database\Model $child, string $related, string $foreignKey, string $ownerKey)getResults(): ?Omnitrix\Database\Modelassociate(?Omnitrix\Database\Model $owner): Omnitrix\Database\Model— Points the child at$owner(or nowhere) without saving.dissociate(): Omnitrix\Database\Model
BelongsToMany (class)
Many-to-many through a pivot table: posts ↔ post_tag(post_id, tag_id) ↔ tags.
__construct(Omnitrix\Database\Model $parent, string $related, string $pivotTable, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey)getResults(): Omnitrix\Database\Collectionget(): Omnitrix\Database\Collectionattach(Omnitrix\Database\Model|array|string|int $ids, array $attributes = …): void— Adds pivot rows linking the parent to the given models or ids.detach(Omnitrix\Database\Model|array|string|int|null $ids = NULL): int— Removes pivot rows for the given models or ids, or all of the parent's rows.sync(array $ids): array— Makes the given ids the complete set of related rows.
HasMany (class)
users.id ← posts.user_id: a user has many posts.
getResults(): Omnitrix\Database\Collection
HasOne (class)
users.id ← profiles.user_id: a user has one profile.
getResults(): ?Omnitrix\Database\Model
HasOneOrMany (abstract class)
Shared behaviour of {@see HasOne} and {@see HasMany}: the related table holds a foreign key
__construct(Omnitrix\Database\Model $parent, string $related, string $foreignKey, string $localKey)create(array $attributes): Omnitrix\Database\Model— Creates a related model with the foreign key set to this parent.save(Omnitrix\Database\Model $model): Omnitrix\Database\Model— Sets the foreign key on an existing model and saves it.
Relation (abstract class)
A relationship between a model and other models. Calling the relation method returns a
__construct(Omnitrix\Database\Model $parent, string $related)getResults(): Omnitrix\Database\Model|Omnitrix\Database\Collection|null— The related models for the parent: a model or null for single relations, a collection forquery(): Omnitrix\Database\ModelQueryget(): Omnitrix\Database\Collectionfirst(): ?Omnitrix\Database\Model
Omnitrix\Database\Schema
Blueprint (class)
Describes a table to create or the changes to apply to an existing one. Used in migrations:
__construct(string $table, bool $creating)id(string $column = 'id'): Omnitrix\Database\Schema\ColumnDefinition— Auto-incrementingBIGINT UNSIGNEDprimary key.bigIncrements(string $column): Omnitrix\Database\Schema\ColumnDefinitionincrements(string $column): Omnitrix\Database\Schema\ColumnDefinitionforeignId(string $column): Omnitrix\Database\Schema\ColumnDefinition—BIGINT UNSIGNEDcolumn meant to reference another table'sid; chain->constrained().string(string $column, int $length = 255): Omnitrix\Database\Schema\ColumnDefinitionchar(string $column, int $length = 255): Omnitrix\Database\Schema\ColumnDefinitiontext(string $column): Omnitrix\Database\Schema\ColumnDefinitionmediumText(string $column): Omnitrix\Database\Schema\ColumnDefinitionlongText(string $column): Omnitrix\Database\Schema\ColumnDefinitionuuid(string $column = 'uuid'): Omnitrix\Database\Schema\ColumnDefinitionenum(string $column, array $values): Omnitrix\Database\Schema\ColumnDefinitionjson(string $column): Omnitrix\Database\Schema\ColumnDefinitionbinary(string $column): Omnitrix\Database\Schema\ColumnDefinitiontinyInteger(string $column): Omnitrix\Database\Schema\ColumnDefinitionsmallInteger(string $column): Omnitrix\Database\Schema\ColumnDefinitioninteger(string $column): Omnitrix\Database\Schema\ColumnDefinitionbigInteger(string $column): Omnitrix\Database\Schema\ColumnDefinitionunsignedInteger(string $column): Omnitrix\Database\Schema\ColumnDefinitionunsignedBigInteger(string $column): Omnitrix\Database\Schema\ColumnDefinitiondecimal(string $column, int $precision = 8, int $scale = 2): Omnitrix\Database\Schema\ColumnDefinitionfloat(string $column): Omnitrix\Database\Schema\ColumnDefinitiondouble(string $column): Omnitrix\Database\Schema\ColumnDefinitionboolean(string $column): Omnitrix\Database\Schema\ColumnDefinitiondate(string $column): Omnitrix\Database\Schema\ColumnDefinitiontime(string $column): Omnitrix\Database\Schema\ColumnDefinitiondateTime(string $column, int $precision = 0): Omnitrix\Database\Schema\ColumnDefinitiontimestamp(string $column, int $precision = 0): Omnitrix\Database\Schema\ColumnDefinitiontimestamps(): void— Nullablecreated_atandupdated_at, maintained by models with timestamps enabled.primary(array|string $columns, ?string $name = NULL): voidunique(array|string $columns, ?string $name = NULL): voidindex(array|string $columns, ?string $name = NULL): voidfullText(array|string $columns, ?string $name = NULL): voidforeign(array|string $columns): Omnitrix\Database\Schema\ForeignKeyDefinitiondropColumn(string ...$columns): voidrenameColumn(string $from, string $to): voiddropIndex(string $name): void— Drops an index by name (see {@see indexName()} for generated names).dropForeign(string $name): void— Drops a foreign key by name (see {@see indexName()} for generated names).columns(): arrayforeignKeys(): arrayindexes(): array— Explicit indexes plus those declared on columns (->unique(),->index()).droppedColumns(): arraydroppedIndexes(): arraydroppedForeignKeys(): arrayrenamedColumns(): arrayindexName(string $type, array $columns): string— Generated constraint name:{table}_{columns}_{type}, e.g.posts_user_id_foreign.static guessTable(string $column): string—user_id→users,category_id→categories.
ColumnDefinition (class)
One column of a {@see Blueprint}. Modifiers return the definition so they can be chained:
__construct(string $name, string $type, array $parameters = …, ?Omnitrix\Database\Schema\Blueprint $blueprint = NULL)nullable(bool $nullable = true): Omnitrix\Database\Schema\ColumnDefinitiondefault(Omnitrix\Core\Database\Query\Expression|string|int|float|bool|null $value): Omnitrix\Database\Schema\ColumnDefinitionunsigned(): Omnitrix\Database\Schema\ColumnDefinitionautoIncrement(): Omnitrix\Database\Schema\ColumnDefinitionprimary(): Omnitrix\Database\Schema\ColumnDefinitionunique(): Omnitrix\Database\Schema\ColumnDefinitionindex(): Omnitrix\Database\Schema\ColumnDefinitioncomment(string $comment): Omnitrix\Database\Schema\ColumnDefinitionafter(string $column): Omnitrix\Database\Schema\ColumnDefinition— Places the column after another one (ALTER TABLE only).useCurrent(): Omnitrix\Database\Schema\ColumnDefinition—DEFAULT CURRENT_TIMESTAMPfor timestamp and datetime columns.useCurrentOnUpdate(): Omnitrix\Database\Schema\ColumnDefinition—ON UPDATE CURRENT_TIMESTAMPfor timestamp and datetime columns.charset(string $charset): Omnitrix\Database\Schema\ColumnDefinitioncollation(string $collation): Omnitrix\Database\Schema\ColumnDefinitionconstrained(?string $table = NULL, string $column = 'id'): Omnitrix\Database\Schema\ForeignKeyDefinition— Adds a foreign key on this column referencing$table.$column. Without a table name it
ForeignKeyDefinition (class)
A foreign key constraint: $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete().
__construct(array $columns)references(string ...$columns): Omnitrix\Database\Schema\ForeignKeyDefinitionon(string $table): Omnitrix\Database\Schema\ForeignKeyDefinitionname(string $name): Omnitrix\Database\Schema\ForeignKeyDefinitiononDelete(string $action): Omnitrix\Database\Schema\ForeignKeyDefinitiononUpdate(string $action): Omnitrix\Database\Schema\ForeignKeyDefinitioncascadeOnDelete(): Omnitrix\Database\Schema\ForeignKeyDefinitionnullOnDelete(): Omnitrix\Database\Schema\ForeignKeyDefinitionrestrictOnDelete(): Omnitrix\Database\Schema\ForeignKeyDefinitioncascadeOnUpdate(): Omnitrix\Database\Schema\ForeignKeyDefinition
Schema (class)
Creates, changes and drops tables on one connection (MySQL/MariaDB). Migrations receive an
__construct(Omnitrix\Core\Database\Database $db)create(string $table, callable $define): voidtable(string $table, callable $define): voiddrop(string $table): voiddropIfExists(string $table): voidrename(string $from, string $to): voidhasTable(string $table): boolhasColumn(string $table, string $column): booltables(): arraydropAllTables(): void— Drops every table of the current database, ignoring foreign keys while doing so. Used bytoSql(Omnitrix\Database\Schema\Blueprint $blueprint): array
SchemaGrammar (class)
Compiles {@see Blueprint}s into MySQL/MariaDB DDL statements.
compile(Omnitrix\Database\Schema\Blueprint $blueprint): arraycompileCreate(Omnitrix\Database\Schema\Blueprint $blueprint): stringcompileAlter(Omnitrix\Database\Schema\Blueprint $blueprint): arraycompileDrop(string $table, bool $ifExists): stringcompileRename(string $from, string $to): stringwrap(string $identifier): stringcolumn(Omnitrix\Database\Schema\ColumnDefinition $column, bool $inlinePrimary): string
Omnitrix\Database\Seeding
Seeder (abstract class)
Fills the database with data. php omnitrix db:seed runs Database\Seeds\DatabaseSeeder,
run(): voidcall(string ...$seeders): void
Omnitrix\Facades
Async (class)
Public entry point for structured concurrency (documentation: Async & services → Concurrency).
static all(array $tasks, ?float $timeout = NULL, ?int $concurrency = NULL): arraystatic allSettled(array $tasks, ?float $timeout = NULL, ?int $concurrency = NULL): arraystatic race(array $tasks, ?float $timeout = NULL): mixedstatic withTimeout(callable $body, float $timeout): mixedstatic scope(callable $body, ?int $concurrency = NULL): mixedstatic sleep(float $seconds): void
Cache (class)
Application cache (documentation: Async & services → Redis and cache).
static store(): Omnitrix\Core\Cache\Cachestatic get(string $key, mixed $default = NULL): mixedstatic set(string $key, mixed $value, ?int $ttl = NULL): boolstatic add(string $key, mixed $value, ?int $ttl = NULL): boolstatic has(string $key): boolstatic delete(string ...$keys): intstatic remember(string $key, ?int $ttl, callable $compute): mixedstatic increment(string $key, int $by = 1): int
Cpu (class)
CPU worker pool (documentation: Async & services → CPU pool).
static pool(): Omnitrix\Core\Process\CpuPoolstatic run(string $job, array $args = …, ?float $timeout = NULL): mixed
DB (class)
Database access (documentation: Database).
static manager(): Omnitrix\Core\Database\DatabaseManagerstatic connection(?string $name = NULL): Omnitrix\Core\Database\Databasestatic table(string $table): Omnitrix\Core\Database\Query\Builderstatic query(): Omnitrix\Core\Database\Query\Builderstatic select(string $sql, array $bindings = …): arraystatic selectOne(string $sql, array $bindings = …): ?arraystatic execute(string $sql, array $bindings = …): intstatic insert(string $sql, array $bindings = …): intstatic transaction(callable $callback, int $attempts = 1): mixedstatic raw(string $sql, array $bindings = …): Omnitrix\Core\Database\Query\Expression
Facade (abstract class)
Static accessors over worker-scoped services.
static setContainer(?Psr\Container\ContainerInterface $container): voidstatic container(): ?Psr\Container\ContainerInterfacestatic hasContainer(): bool
Http (class)
Outbound HTTP (documentation: Async & services → HTTP client).
static client(): Omnitrix\Core\HttpClient\HttpClientstatic request(): Omnitrix\Core\HttpClient\PendingRequeststatic withHeaders(array $headers): Omnitrix\Core\HttpClient\PendingRequeststatic withToken(string $token, string $type = 'Bearer'): Omnitrix\Core\HttpClient\PendingRequeststatic timeout(float $seconds): Omnitrix\Core\HttpClient\PendingRequeststatic retry(int $times, bool $onTimeout = false): Omnitrix\Core\HttpClient\PendingRequeststatic get(string $url, array $query = …): Omnitrix\Core\HttpClient\Responsestatic post(string $url, mixed $json = NULL): Omnitrix\Core\HttpClient\Responsestatic put(string $url, mixed $json = NULL): Omnitrix\Core\HttpClient\Responsestatic patch(string $url, mixed $json = NULL): Omnitrix\Core\HttpClient\Responsestatic delete(string $url): Omnitrix\Core\HttpClient\Responsestatic head(string $url): Omnitrix\Core\HttpClient\Response
Queue (class)
Background jobs (documentation: Async & services → Queues).
static producer(): Omnitrix\Core\Queue\QueueProducerstatic dispatch(string $name, array $payload = …, float $delay = 0.0, ?string $queue = NULL, ?int $maxAttempts = NULL): stringstatic stats(?string $queue = NULL): array
Redis (class)
Redis access (documentation: Async & services → Redis and cache). Typed helpers for common commands; command() for the
static client(): Omnitrix\Core\Redis\RedisClientstatic get(string $key): ?stringstatic set(string $key, string $value, ?int $ttl = NULL): boolstatic delete(string ...$keys): intstatic increment(string $key, int $by = 1): intstatic expire(string $key, int $seconds): boolstatic command(string $name, array $args = …): mixedstatic withConnection(callable $fn): mixedstatic pipeline(callable $commands): arraystatic transaction(callable $commands): arraystatic publish(string $channel, string $message): int
Omnitrix\Http
Cookie (class)
Immutable Set-Cookie description.
__construct(string $name, string $value, int $expires = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httpOnly = true, string $sameSite = 'Lax')static forget(string $name, string $path = '/', string $domain = ''): Omnitrix\Http\Cookie— A cookie that instructs the client to delete$name.
ErrorResponseFactory (class)
Converts any throwable into a JSON error {@see Response}.
__construct(bool $debug = false)fromThrowable(Throwable $e, string $requestId): Omnitrix\Http\ResponseisDebug(): bool
Omnitrix\Http\Exception
BadRequestException (class)
__construct(string $message = 'The request could not be understood', array $headers = …, array $details = …, ?Throwable $previous = NULL)
HttpException (class)
An exception that maps directly to an HTTP response. The message is considered safe to show
__construct(int $status, string $message = '', array $headers = …, array $details = …, ?Throwable $previous = NULL)status(): intheaders(): arraydetails(): array
MethodNotAllowedException (class)
__construct(string $message = 'Method not allowed', array $headers = …, array $details = …, ?Throwable $previous = NULL)
NotFoundException (class)
__construct(string $message = 'Resource not found', array $headers = …, array $details = …, ?Throwable $previous = NULL)
PayloadTooLargeException (class)
__construct(string $message = 'Request body exceeds the allowed size', array $headers = …, array $details = …, ?Throwable $previous = NULL)
ServiceUnavailableException (class)
__construct(string $message = 'Service temporarily unavailable', array $headers = …, array $details = …, ?Throwable $previous = NULL)
UnsupportedMediaTypeException (class)
__construct(string $message = 'Unsupported Content-Type', array $headers = …, array $details = …, ?Throwable $previous = NULL)
Omnitrix\Http
HttpKernel (class)
The per-worker HTTP kernel: request → router → middleware pipeline → handler → response.
__construct(Omnitrix\Routing\Router $router, Omnitrix\Routing\HandlerResolver $resolver, Omnitrix\Http\ErrorResponseFactory $errors, Omnitrix\Core\Runtime\Exception\ExceptionHandlerInterface $exceptionHandler)middleware(Omnitrix\Http\Middleware\MiddlewareInterface|callable ...$middleware): Omnitrix\Http\HttpKernel— Global middleware, run for every matched route in registration order.router(): Omnitrix\Routing\Router__invoke(Omnitrix\Core\Http\Server\IncomingRequest $incoming, Omnitrix\Core\Http\Server\ResponseWriter $writer, Omnitrix\Core\Runtime\Context\RequestContext $context): void— Entry point for the server adapter.handle(Omnitrix\Http\Request $request): Omnitrix\Http\Response— Produces a Response for a Request (also usable without a server, e.g. in tests).
Omnitrix\Http\Middleware
MiddlewareInterface (interface)
Middleware wraps the rest of the pipeline. Call $next($request) to continue, or return a
process(Omnitrix\Http\Request $request, Omnitrix\Http\Middleware\Next $next): Omnitrix\Http\Response
Next (class)
The continuation handed to middleware. Calling it runs the rest of the pipeline.
__construct(Closure $continuation)__invoke(Omnitrix\Http\Request $request): Omnitrix\Http\Response
Pipeline (class)
Compiles a middleware list and a final handler into one closure, once. Dispatch is then a
static compile(array $middleware, callable $handler): Closure
Omnitrix\Http
Request (class)
The request object handed to middleware and route handlers.
context(): Omnitrix\Core\Runtime\Context\RequestContextid(): stringmethod(): stringisMethod(string $method): boolpath(): stringqueryString(): stringquery(): arrayqueryParam(string $name, mixed $default = NULL): mixedheaders(): arrayheader(string $name, ?string $default = NULL): ?stringhasHeader(string $name): boolbearerToken(): ?string— Bearer token from the Authorization header, or null.cookies(): arraycookie(string $name, ?string $default = NULL): ?stringcontentType(): ?stringisJson(): boolbody(): stringjson(): mixedjsonObject(): arrayform(): arrayfiles(): arrayremoteAddress(): ?stringprotocolVersion(): stringinput(string $name, mixed $default = NULL): mixed— A single input value: JSON object field (for JSON requests), then form field, thenall(): array— All input merged (query < form < JSON object), later sources overriding earlier ones.validate(array $rules): array— Validatesall()input against rule strings and returns only the validated fields.routePattern(): ?string— The matched route pattern (bounded cardinality; safe as a metrics label), or null.route(string $name, mixed $default = NULL): mixed— Route parameter (e.g.{id}) as the raw URL segment, or$default.routeInt(string $name): int— Route parameter cast to int; throws a 404 when it is not an integer.routeParams(): arrayrouteName(): ?stringsetAttribute(string $name, mixed $value): voidattribute(string $name, mixed $default = NULL): mixedhasAttribute(string $name): boolattributes(): array
Response (class)
The response value returned by handlers and middleware.
__construct(string $body = '', int $status = 200, array $headers = …)static json(mixed $data, int $status = 200, int $flags = 320): Omnitrix\Http\Responsestatic text(string $body, int $status = 200): Omnitrix\Http\Responsestatic html(string $body, int $status = 200): Omnitrix\Http\Responsestatic noContent(): Omnitrix\Http\Responsestatic redirect(string $location, int $status = 302): Omnitrix\Http\Responsestatic file(string $path, ?string $contentType = NULL, ?string $downloadName = NULL): Omnitrix\Http\Response— Sends a file with sendfile(2).static stream(callable $producer, int $status = 200, string $contentType = 'application/octet-stream'): Omnitrix\Http\Response— Streams through a callback that writes chunks with {@see Stream::write()}; thestatic chunks(iterable $chunks, int $status = 200, string $contentType = 'application/octet-stream'): Omnitrix\Http\Response— Streams every string yielded by the iterable (generators welcome) as a chunk.status(int $status): Omnitrix\Http\Responseheader(string $name, string $value): Omnitrix\Http\Responseheaders(array $headers): Omnitrix\Http\ResponsewithoutHeader(string $name): Omnitrix\Http\Responsecookie(Omnitrix\Http\Cookie $cookie): Omnitrix\Http\ResponsegetStatus(): intgetHeader(string $name): ?stringgetHeaders(): arraygetCookies(): arraybodyType(): intgetBody(): stringgetFile(): ?stringgetStream(): ?ClosuregetChunks(): ?iterable
Stream (class)
The body of a streaming response, handed to the producer of {@see Response::stream()}.
write(string $chunk): bool— Sends a chunk; false when the client is gone.clientGone(): bool— True once a write reported that the client disconnected.bytesWritten(): int— Bytes sent so far.
Omnitrix\Observability
AccessLog (class)
One structured log line per request: method, route pattern, path, status, duration, request
__construct(Psr\Log\LoggerInterface $logger, array $skipPaths = …)process(Omnitrix\Http\Request $request, Omnitrix\Http\Middleware\Next $next): Omnitrix\Http\Response
HealthCheck (class)
Liveness and readiness. Readiness runs every registered check concurrently with a timeout;
__construct(float $timeout = 2.0)add(string $name, callable $check): Omnitrix\Observability\HealthChecklive(): Omnitrix\Http\Responseready(): Omnitrix\Http\Response
Omnitrix
Omnitrix (class)
Framework identity constants.
Omnitrix\Queue
Worker (class)
A background job consumer process.
__construct(array $config, string $queue = 'default', int $concurrency = 4, float $jobTimeout = 60.0, float $backoffBase = 1.0, ?Psr\Log\LoggerInterface $logger = NULL)handle(string $job, callable $handler): Omnitrix\Queue\Worker— Registers the handler for one job name.run(): int— Processes jobs until terminated; returns 0 after a graceful stop.stats(): array
Omnitrix\RateLimit
RateLimit (class)
Rate limiting middleware. Keyed by authenticated identity when present, otherwise by client
__construct(Omnitrix\RateLimit\RateLimiterInterface $limiter, int $limit, int $windowSeconds = 60, ?callable $key = NULL, string $name = 'default', ?callable $onError = NULL)process(Omnitrix\Http\Request $request, Omnitrix\Http\Middleware\Next $next): Omnitrix\Http\Response
RateLimitResult (class)
__construct(bool $allowed, int $limit, int $remaining, int $retryAfter)
RateLimiterInterface (interface)
Counts hits per key in fixed windows.
hit(string $key, int $limit, int $windowSeconds): Omnitrix\RateLimit\RateLimitResult— Records one hit and returns the decision.
RedisRateLimiter (class)
Fixed-window limiter shared by every worker and server (INCR + EXPIRE in one Lua call, so the
__construct(?Omnitrix\Core\Redis\RedisClient $redis = NULL, string $prefix = 'ratelimit:')hit(string $key, int $limit, int $windowSeconds): Omnitrix\RateLimit\RateLimitResult
TableRateLimiter (class)
Fixed-window limiter in OpenSwoole shared memory: shared by every worker of one server (create
__construct(int $maxKeys = 65536)hit(string $key, int $limit, int $windowSeconds): Omnitrix\RateLimit\RateLimitResult
Omnitrix\Routing
HandlerResolver (class)
Turns a route handler declaration into a Closure(Request): Response-like callable, once
__construct(?Psr\Container\ContainerInterface $container = NULL)resolve(mixed $handler): Closure
Route (class)
A registered route: methods, path pattern, handler, middleware and an optional name.
__construct(array $methods, string $pattern, mixed $handler)middleware(Omnitrix\Http\Middleware\MiddlewareInterface|callable ...$middleware): Omnitrix\Routing\Routename(string $name): Omnitrix\Routing\RoutegetName(): ?stringgetMiddleware(): arraysetPipeline(Closure $pipeline): voidgetPipeline(): ?Closure
RouteMatch (class)
Result of a successful dispatch.
__construct(Omnitrix\Routing\Route $route, array $params)
Router (class)
Route registration and dispatch on top of FastRoute's GroupCountBased engine.
get(string $pattern, mixed $handler): Omnitrix\Routing\Routepost(string $pattern, mixed $handler): Omnitrix\Routing\Routeput(string $pattern, mixed $handler): Omnitrix\Routing\Routepatch(string $pattern, mixed $handler): Omnitrix\Routing\Routedelete(string $pattern, mixed $handler): Omnitrix\Routing\Routeoptions(string $pattern, mixed $handler): Omnitrix\Routing\Routeany(string $pattern, mixed $handler): Omnitrix\Routing\Routemap(array $methods, string $pattern, mixed $handler): Omnitrix\Routing\Routegroup(string $prefix, callable $define, array $middleware = …): void— Defines routes under a common prefix and middleware set.routes(): arrayisCompiled(): boolcompile(): void— Builds the dispatcher data. Idempotent.dispatch(string $method, string $path): Omnitrix\Routing\RouteMatchroutesFor(string $method): arraypipelineFor(Omnitrix\Routing\Route $route, Closure $factory): Closure— Returns the route's compiled pipeline, building it with$factoryon first use.
Omnitrix\Security
Authorize (class)
Authorization hook: Authorize::ability('orders.write') or a custom policy
__construct(callable $policy)static ability(string $ability): Omnitrix\Security\Authorizeprocess(Omnitrix\Http\Request $request, Omnitrix\Http\Middleware\Next $next): Omnitrix\Http\Response
BearerTokenAuth (class)
Authenticates Authorization: Bearer <token> through an application-supplied resolver
__construct(callable $resolver, bool $optional = false)process(Omnitrix\Http\Request $request, Omnitrix\Http\Middleware\Next $next): Omnitrix\Http\Responsestatic identity(Omnitrix\Http\Request $request): ?Omnitrix\Security\Identity
Identity (class)
The authenticated principal attached to a request by {@see BearerTokenAuth}.
__construct(string $id, array $abilities = …, array $claims = …)can(string $ability): bool
SecurityHeaders (class)
Adds conservative security headers suited to JSON APIs (only where the handler did not set them).
__construct(array $headers = …, bool $hsts = false)process(Omnitrix\Http\Request $request, Omnitrix\Http\Middleware\Next $next): Omnitrix\Http\Response
Omnitrix\Support
Str (class)
Naming helpers used for table, class and file names. English pluralisation rules only.
static snake(string $value): string—UserProfile,userProfile,user-profile→user_profile.static studly(string $value): string—user_profile,user-profile,user profile→UserProfile.static camel(string $value): string—user_profile→userProfile.static plural(string $word): string—post→posts,category→categories,user_profile→user_profiles.static singular(string $word): string—posts→post,categories→category.
Omnitrix\Validation
ValidationException (class)
422 with field errors: {"error": {"status": 422, "message": "...", "errors": {field: [messages]}}}.
__construct(array $errors)
Validator (class)
Small rule-string validator for request input.
__construct(array $rules)validate(array $input): array