PHP.GT

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:

  • --port changes the port number
  • --bind changes the host or interface to bind to
  • --threads changes the worker count used by the underlying server command
  • --debug enables 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-build is supplied
  • gt cron --watch, if a crontab file exists and --no-cron is 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 crontab during 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.