Server
The server:start command runs a local development server for your application from the console. It wraps PHP's built-in web server by default, and can switch to a Swoole engine for long-running processes. You do not need to configure Apache or Nginx while developing.
Starting a Server
Run server:start with the server name, using the php:main format. The name points to an entry in the server registry.
php windwalker server:startThe command keeps running until you stop it.
Server Registry
The server argument uses the {engine:name} format. Each entry maps an engine and a name to a main file in resources/registry/servers.php.
// resources/registry/servers.php
return [
'swoole' => [
'main' => __DIR__ . '/../../bin/swoole-main.php',
],
'php' => [
'main' => __DIR__ . '/../../www/index.php',
],
];If the name is not registered, the command fails.
// ERROR: Main file not found for engine: swoole - name: otherEngines
The engine comes from the prefix of the server argument. The --engine option is used only when the argument has no prefix. The argument defaults to php:main, so --engine has no effect unless you pass a bare name.
php: runsphp -Swith the document root or a main file. Use it for standard web requests.swoole: starts a Swoole server with a state file, workers, and an optional file watcher. See the Swoole page.
php windwalker server:start swoole:mainOptions
Port and Host
The default host is localhost. If you omit --port, the command scans from port 8000 upward and uses the first free port.
php windwalker server:start --host=0.0.0.0 --port=9000Document Root and Main File
For php, the document root defaults to the www directory of the project. Use --docroot to change it. Use --main to route every request through one file.
php windwalker server:start --docroot=public
php windwalker server:start --main=bin/router.phpSwoole Options
These options apply only to the swoole engine.
php windwalker server:start swoole:main \
--workers=4 \
--task-workers=2 \
--max-requests=500 \
--watch--workers: number of worker processes.--task-workers: number of task worker processes.--max-requests: requests a worker handles before it restarts. The default is500.--watch: reloads the workers when a source file changes.
Stopping a Server
Stop a php server by pressing Ctrl+C in the terminal.
The server:stop command stops a Swoole server that was started in the background. It does not stop a php server.
php windwalker server:stop swoole:main// ERROR: Server is not running.INFO
The --engine help text of server:stop lists swoole with a default of php. The default is never used, because the server argument always has a prefix. Pass the engine in the argument.
Signal Handling
On Linux and macOS, server:start listens for SIGINT and SIGTERM. When the Swoole engine is running, the signal stops the server before the command exits. Windows does not support these signals, so use Ctrl+C or server:stop there.