Skip to content

Latest commit

 

History

History
375 lines (267 loc) · 6.35 KB

File metadata and controls

375 lines (267 loc) · 6.35 KB

HttpServer

  • class HttpServer (php\http\HttpServer)
  • package http
  • source php/http/HttpServer.php

Description

Class HttpServer


Methods


Methods

__construct()

__construct(int $port, string $host): void

Server constructor.


stopAtShutdown()

stopAtShutdown(bool $value): bool

If true, this server instance will be explicitly stopped when the JVM is shutdown. Otherwise the JVM is stopped with the server running.


minThreads()

minThreads(int $min): int

maxThreads()

maxThreads(int $max): int

threadIdleTimeout()

threadIdleTimeout(int $timeout): int

listen()

listen(string $portOrHostPort): void

Add connector to server: 127.0.0.1:8080 8080, 127.0.0.1


unlisten()

unlisten(string $portOrHostPort): void

connectors()

connectors(): string[]

All connectors (host+port)


run()

run(): void

Run server in current thread.


runInBackground()

runInBackground(): void

Run server in background thread.


shutdown()

shutdown(): void

Stop server.


handlers()

handlers(): callable[]

filters()

filters(): callable[]

addWebSocket()

addWebSocket(string $path, array $handlers): void

addFilter()

addFilter(callable $callback): void

addHandler()

addHandler(callable $callback): void

clearHandlers()

clearHandlers(): void

Remove all handlers.


setRequestLogHandler()

setRequestLogHandler([ callable|null $handler): void

setErrorHandler()

setErrorHandler([ callable|null $handler): void

isRunning()

isRunning(): bool

isFailed()

isFailed(): bool

isStopped()

isStopped(): bool

isStopping()

isStopping(): bool

isStarting()

isStarting(): bool

filtrate()

filtrate(string|array $methods, string $path, callable $filter): php\http\HttpRouteFilter

route()

route(string|array $methods, string $path, callable $handler): php\http\HttpRouteHandler

Route a handler by method and path.


any()

any(string $path, callable $handler): php\http\HttpRouteHandler

Route any methods.


get()

get(string $path, callable $handler): php\http\HttpRouteHandler

Route a handler by GET method + path.


post()

post(string $path, callable $handler): php\http\HttpRouteHandler

Route a handler by POST method + path.


put()

put(string $path, callable $handler): php\http\HttpRouteHandler

Route a handler by PUT method + path.


delete()

delete(string $path, callable $handler): php\http\HttpRouteHandler

Route a handler by DELETE method + path.


options()

options(string $path, callable $handler): php\http\HttpRouteHandler

Route a handler by OPTIONS method + path.


patch()

patch(string $path, callable $handler): php\http\HttpRouteHandler

Route a handler by PATCH method + path.


head()

head(string $path, callable $handler): php\http\HttpRouteHandler

Route a handler by HEAD method + path.