Running a project locally
Once a project exists, the commands most people use day to day are gt run and gt serve.
gt serve starts only the local web server.
gt run starts the server and, where appropriate, the other long-running development processes alongside it.
gt serve
Basic usage:
gt serve [--port|-p PORT] [--bind|-b BIND] [--threads|-t THREADS] [--debug|-d]
Examples:
gt serve
gt serve --port 8081
gt serve --bind 127.0.0.1 --port 9000
gt serve --debug
This command is the simplest way to serve a WebEngine project locally.
Useful options:
--portchanges the port number--bindchanges the host or interface to bind to--threadschanges the worker count used by the underlying server command--debugenables debug output in the server layer
gt run
Basic usage:
gt run [--port|-p PORT] [--bind|-b BIND] [--debug|-d] [--no-build] [--no-cron]
Examples:
gt run
gt run --port 8081
gt run --no-build
gt run --no-cron
gt run is intended as the normal local development command.
gt run combines multiple commands
When running gt run, it also starts:
gt build --watch, unless--no-buildis suppliedgt cron --watch, if acrontabfile exists and--no-cronis not supplied
That gives us one foreground command for the usual WebEngine development setup.
Default local URL
With the default settings, the command prints:
http://localhost:8080
Even though the default bind value is 0.0.0.0, the displayed browser URL is normalised to localhost for convenience.
When to prefer run over serve
Use gt run when:
- you want asset builds to keep running while you work
- your project uses a
crontabduring development - you would rather not think about several separate terminal windows
Use gt serve when:
- you only need the web server
- you are debugging one part of the stack at a time
- another tool is already handling asset builds
Next, see Build, cron, and migrate commands for the commands that gt exposes from the wider PHP.GT toolchain.