Skip to content

Web servers

samme edited this page Apr 26, 2023 · 12 revisions

For most Phaser work you need to run a web server on your device ("locally").

After you start the server you'll open your web page at an URL like http://127.0.0.1:8080 or http://localhost:8080. The port (8080) can vary.

Opening a web page from file:// (such as by double-clicking it) won't work, since no web server is involved.

Multiplatform

http-server

http-server is a good choice.

Install once:

npm i -g http-server

Go to your project directory and run:

cd my-phaser-project
http-server . -c-1 --open

-c-1 means don't cache and --open means open a browser.

http-server will serve from a public folder in the current directory (if it exists) or the current directory.

More http-server options:

  • -d-1 no directory listings
  • -i-1 no auto index (i.e., / -> /index.html)
  • --no-dotfiles
  • -s no terminal output

express

express is quite unnecessary unless you're writing server code (e.g., multiplayer).

Mac OS

python3 -m http.server

ruby -run -ehttpd . -p8000

Unix

python  -m http.server 8000

Windows

  • Laragon
  • WAMP is probably more trouble than it's worth
Clone this wiki locally