メインコンテンツへスキップ

@php-wasm/universal

Index

Classes

Functions

Interfaces

Namespaces

References

Type Aliases

Variables

References

SpawnedPHP

Renames and re-exports AcquiredPHP

WithAPIState

Renames and re-exports WithIsReady

Type Aliases

ByteRange

ByteRange: { end: bigint; start: bigint }

Type declaration

  • end: bigint
  • start: bigint

ConflictingLockedRange

ConflictingLockedRange: Omit<LockedRange, fd>

DataModule

DataModule: { default: (phpRuntime: PHPRuntime) => void; dependenciesTotalSize: number; dependencyFilename: string }

Type declaration

  • default: (phpRuntime: PHPRuntime) => void
  • dependenciesTotalSize: number
  • dependencyFilename: string

EmscriptenOptions

EmscriptenOptions: { ENV?: Record<string, string>; debug?: boolean; instantiateWasm?: (info: WebAssembly.Imports, receiveInstance: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void) => void; locateFile?: (path: string) => string; monitorRunDependencies?: (left: number) => void; noInitialRun?: boolean; onAbort?: (message: string) => void; onMessage?: (listener: EmscriptenMessageListener) => void; onRuntimeInitialized?: (phpRuntime: PHPRuntime) => void; outboundNetworkProxyServer?: Server<typeof IncomingMessage, typeof ServerResponse>; print?: (message: string) => void; printErr?: (message: string) => void; quit?: (status: number, toThrow: any) => void } & Record<string, any>

Fd

Fd: number

FileLockManager

FileLockManager: { findFirstConflictingByteRangeLock: (path: Path, desiredLock: RequestedRangeLock) => Omit<RequestedRangeLock, fd> | undefined; lockFileByteRange: (path: Path, requestedLock: RequestedRangeLock, waitForLock: boolean) => boolean; lockWholeFile: (path: Path, op: WholeFileLockOp) => boolean; releaseLocksForProcess: (pid: number) => void; releaseLocksOnFdClose: (pid: number, fd: number, path: Path) => void }

This is an interface used to abstract byte range locking like fcntl() and whole-file locking like flock().


Type declaration

  • findFirstConflictingByteRangeLock: (path: Path, desiredLock: RequestedRangeLock) => Omit<RequestedRangeLock, fd> | undefined

    Get the first lock that would conflict with the specified lock.

    This method is meant to satisfy the needs of the F_GETLK fcntl() command. https://sourceware.org/glibc/manual/2.41/html_node/File-Locks.html#index-F_005fGETLK-1

    @returns

    A promise for the first conflicting lock, or undefined if there is no conflict.

  • lockFileByteRange: (path: Path, requestedLock: RequestedRangeLock, waitForLock: boolean) => boolean

    Update the lock on a byte range of a file.

    This method is for locking with the F_SETLK fcntl() command. https://sourceware.org/glibc/manual/2.41/html_node/File-Locks.html#index-F_005fSETLK-1

    @returns

    A promise for a boolean value. When locking: True if the lock was acquired, false if it was not. When unlocking: Always true.

      • Parameters

        • path: Path

          The path of the file to lock. This should be the path of the file in the underlying filesystem.

        • requestedLock: RequestedRangeLock

          The lock to request, including start, end, type, and pid.

        • waitForLock: boolean

          Whether to block until the lock is acquired.

        Returns boolean

  • lockWholeFile: (path: Path, op: WholeFileLockOp) => boolean

    Update the lock on the whole file.

    This method is for updating the lock on the whole file with the F_SETLKW fcntl() command. https://sourceware.org/glibc/manual/2.41/html_node/File-Locks.html#index-F_005fSETLKW-1

    @returns

    A promise for a boolean value.

      • Parameters

        • path: Path

          The path of the file to lock. This should be the path of the file in the underlying filesystem.

        • op: WholeFileLockOp

          The operation to perform, including 'shared', 'exclusive', or 'unlock'.

        Returns boolean

  • releaseLocksForProcess: (pid: number) => void

    Release all locks for a given process.

    Used when a process exits or is otherwise terminated.

      • (pid: number): void
      • Parameters

        • pid: number

          The PID of the process that wants to release the locks.

        Returns void

  • releaseLocksOnFdClose: (pid: number, fd: number, path: Path) => void

    Release all locks for the given process and file descriptor.

      • (pid: number, fd: number, path: Path): void
      • Parameters

        • pid: number

          The process ID to release locks for.

        • fd: number

          The file descriptor to release locks for.

        • path: Path

          The path to the file to release locks for. This should be the path of the file in the underlying filesystem.

        Returns void

FileNotFoundAction

FileNotFoundAction: FileNotFoundToResponse | FileNotFoundToInternalRedirect | FileNotFoundTo404

FileNotFoundGetActionCallback

FileNotFoundGetActionCallback: (relativePath: string) => FileNotFoundAction

Type declaration

FileNotFoundToInternalRedirect

FileNotFoundToInternalRedirect: { type: internal-redirect; uri: string }

Type declaration

  • type: internal-redirect
  • uri: string

FileNotFoundToResponse

FileNotFoundToResponse: { response: PHPResponse; type: response }

Type declaration

HTTPMethod

HTTPMethod: GET | POST | HEAD | OPTIONS | PATCH | PUT | DELETE

IterateFilesOptions

IterateFilesOptions: { exceptPaths?: string[]; pathPrefix?: string; relativePaths?: boolean }

Type declaration

  • optionalexceptPaths?: string[]

    A list of paths to exclude from the results.

  • optionalpathPrefix?: string

    A prefix to add to all paths. Only used if relativePaths is true.

  • optionalrelativePaths?: boolean

    Should yield paths relative to the root directory? If false, all paths will be absolute.

LockedRange

LockedRange: RequestedRangeLock & { type: Exclude<RequestedRangeLock[type], unlocked> }

MessageListener

MessageListener: (data: string) => Promise<string | Uint8Array | void> | string | void

Type declaration

    • (data: string): Promise<string | Uint8Array | void> | string | void
    • Parameters

      • data: string

      Returns Promise<string | Uint8Array | void> | string | void

MountHandler

MountHandler: (php: PHP, FS: Emscripten.RootFS, vfsMountPoint: string) => UnmountFunction | Promise<UnmountFunction>

Type declaration

PHPEvent

PHPEvent: PHPRequestEndEvent | PHPRequestErrorEvent | PHPRuntimeInitializedEvent | PHPRuntimeBeforeExitEvent | PHPFilesystemWriteEvent

Represents an event related to the PHP instance. This is intentionally not an extension of CustomEvent to make it isomorphic between different JavaScript runtimes.

PHPEventListener

PHPEventListener: (event: PHPEvent) => void

A callback function that handles PHP events.


Type declaration

PHPFactory

PHPFactory: (options: PHPFactoryOptions) => Promise<PHP>

Type declaration

PHPFactoryOptions

PHPFactoryOptions: { isPrimary: boolean }

Type declaration

  • isPrimary: boolean

PHPLoaderModule

PHPLoaderModule: { dependenciesTotalSize: number; dependencyFilename: string; init: (jsRuntime: string, options: EmscriptenOptions) => PHPRuntime }

Type declaration

PHPRequestHandlerConfiguration

PHPRequestHandlerConfiguration: BaseConfiguration & { cookieStore?: CookieStore | false; maxPhpInstances?: number; php?: PHP; phpFactory?: (requestHandler: PHPRequestHandlerFactoryArgs) => Promise<PHP> }

PHPRequestHeaders

PHPRequestHeaders: Record<string, string>

PHPRuntime

PHPRuntime: any

PHPRuntimeId

PHPRuntimeId: number

Path

Path: string

PathAlias

PathAlias: { fsPath: string; urlPrefix: string }

Maps a URL path prefix to an absolute filesystem path. Similar to Nginx's alias directive or Apache's Alias directive.

@example
// Requests to /phpmyadmin/* will be served from /tools/phpmyadmin/*
{ urlPrefix: '/phpmyadmin', fsPath: '/tools/phpmyadmin' }

Type declaration

  • fsPath: string

    The absolute filesystem path to serve files from.

  • urlPrefix: string

    The URL path prefix to match (e.g., '/phpmyadmin').

Pid

Pid: number

Pooled

Pooled<T>: Omit<Promisified<T>, typeof Symbol.dispose | typeof Symbol.asyncDispose>

The type returned by createObjectPoolProxy. All method calls and property accesses are wrapped in promises because acquiring a free pool instance is inherently async.

Dispose/asyncDispose symbols are omitted because the pool proxy forwards calls to a single random instance — disposing one instance out of the pool is never the intended behavior. Pool lifecycle should be managed by the code that created the pool.


Type parameters

  • T: object

PublicAPI

PublicAPI<Methods, PipedAPI>: RemoteAPI<Methods & PipedAPI>

Type parameters

  • Methods
  • PipedAPI = unknown

Remote

Remote<T>: RemoteObject<T> & (T extends (...args: infer TArguments) => infer TReturn ? (...args: { [ I in keyof TArguments ]: UnproxyOrClone<TArguments[I]> }) => Promisify<ProxyOrClone<Unpromisify<TReturn>>> : unknown) & (T extends new (...args: TArguments) => TInstance ? new (...args: { [ I in string | number | symbol ]: UnproxyOrClone<TArguments[I<I>]> }) => Promisify<Remote<TInstance>> : unknown) & ProxyMethods

Takes the raw type of a remote object, function or class in the other thread and returns the type as it is visible to the local thread from the proxy return value of Comlink.wrap() or Comlink.proxy().


Type parameters

  • T

RemoteAPI

RemoteAPI<T>: Remote<T> & ProxyMethods & WithAPIState

Type parameters

  • T

RequestedRangeLock

RequestedRangeLock: ByteRange & { fd: Fd; pid: Pid; type: shared | exclusive | unlocked }

RewriteRule

RewriteRule: { match: RegExp; replacement: string }

Type declaration

  • match: RegExp
  • replacement: string

RuntimeType

RuntimeType: NODE | WEB | WORKER

SpawnHandler

SpawnHandler: (command: string, args: string[]) => ChildProcess

Type declaration

    • (command: string, args: string[]): ChildProcess
    • Parameters

      • command: string
      • args: string[]

      Returns ChildProcess

SupportedPHPVersion

SupportedPHPVersion: typeof SupportedPHPVersions[number]

UniversalPHP

UniversalPHP: LimitedPHPApi | Remote<LimitedPHPApi> | Pooled<LimitedPHPApi>

UnmountFunction

UnmountFunction: () => Promise<any> | () => any

WholeFileLock

WholeFileLockOp

WholeFileLockOp: { fd: number; pid: number; type: shared | exclusive; waitForLock: boolean } | { fd: number; pid: number; type: unlock }

WholeFileLock_Exclusive

WholeFileLock_Exclusive: { fd: Fd; pid: Pid; type: exclusive }

Type declaration

  • fd: Fd
  • pid: Pid
  • type: exclusive

WholeFileLock_Shared

WholeFileLock_Shared: { pidFds: Map<Pid, Set<Fd>>; type: shared }

Type declaration

  • pidFds: Map<Pid, Set<Fd>>

    NOTE: flock() locks are associated with open file descriptors and duplicated file descriptors. We do not currently recognize duplicate file descriptors.

  • type: shared

WholeFileLock_Unlocked

WholeFileLock_Unlocked: { type: unlocked }

Type declaration

  • type: unlocked

WithIsReady

WithIsReady: { isConnected: () => Promise<void>; isReady: () => Promise<void> }

Type declaration

  • isConnected: () => Promise<void>

    Resolves to true when the remote API is ready for Comlink communication, but not necessarily fully initialized yet.

      • (): Promise<void>
      • Returns Promise<void>

  • isReady: () => Promise<void>

    Resolves to true when the remote API is declares it's fully loaded and ready to be used.

      • (): Promise<void>
      • Returns Promise<void>

Variables

constDEFAULT_BASE_URL

DEFAULT_BASE_URL: http://example.com = 'http://example.com'

The default base used to convert a path into the URL object.

constLatestSupportedPHPVersion

LatestSupportedPHPVersion: 8.5 = ...

constMAX_ADDRESSABLE_FILE_OFFSET

MAX_ADDRESSABLE_FILE_OFFSET: bigint = ...

constSupportedPHPVersions

SupportedPHPVersions: readonly [8.5, 8.4, 8.3, 8.2, 8.1, 8.0, 7.4] = ...

constSupportedPHPVersionsList

SupportedPHPVersionsList: string[] = ...

const__private__dont__use

__private__dont__use: typeof __private__dont__use = ...

constreleaseApiProxy

releaseApiProxy: typeof releaseProxy = releaseProxy