# Developing locally

With the **dev kit** you run the frontend on your own computer. It shows a site's **staging** content (or another environment that is not live), drawn with the theme in **your own folder**. When you change your theme, you see it on the next reload. When someone changes content in Lightbolt, you see it within about 15 seconds.

## What the dev kit is

The dev kit is a zip with three parts:

- **The engine.** It is the same version as the site's environment runs. It only includes the themes your theme builds on, such as `classic` and `base`. It never includes another client's theme.
- **A Docker setup.** It uses the same PHP as the servers (8.5) and PHP's own small web server. You do not need Apache, a vhost or a database.
- **A README and a sample config.** The README has the steps below. In the sample config, Lightbolt's address, the site, the environment and a local address are already filled in.

The engine gets the site's content from Lightbolt with a **developer token**. It draws that content with the theme from your own folder. Your folder wins over the theme version chosen in Lightbolt.

**Why Docker and not XAMPP?** XAMPP for Windows stops at PHP 8.2, and the servers run PHP 8.5. With Docker, every developer runs exactly the same PHP.

## What you need

- **Docker.** Use Docker Desktop on Windows or macOS, or Docker Engine on Linux.
- **The theme repository**, checked out on your computer. See [Themes from Bitbucket or GitHub](/md/docs/themes/from-bitbucket/).
- **A developer token.** There are two kinds:
  - **Your own token** is the easiest. You make it under **Profile → Developer tokens**. It reads every site of your organisation that you may open. Your account needs a second factor for it. See [Tokens](/md/docs/start/tokens/).
  - **A token for one site** is made under the site's **Domains and environments → Developer tokens**. Give it a name, such as *Anna, laptop*, and choose the environment, usually staging.

Both kinds only read, never reach live, and stop after 180 days. You see a new token only once. Keep it until step 3 below, and never put it in git or a chat. Make one token per developer and per computer, so you can stop each one on its own.

## Your folders

You can arrange your folders as you like. The kit only needs three things:

1. **One folder holds every theme you work on.** The themes can be at any depth inside it. `THEMES` in `.env` points to this folder, and Docker shows it to the engine as `/themes`. Are your themes in folders far apart? Then add a line per folder under `volumes` in `compose.yml`. That is your own change, so redo it after you download a new kit.
2. **Each theme folder is named after the theme's key.** `theme_dir` in `lightbolt/config.php` tells the engine where to look. In it, `{key}` stands for the theme's key. Some examples:
   - `/themes`: the theme folders are directly in the `THEMES` folder;
   - `/themes/{key}/www`: each theme is in a `www` folder inside its own folder;
   - `/themes/clients/{key}/site/www`: deeper is fine too.
   The folders before `{key}` must exist. If they do not, the engine uses the theme version the environment chose instead.
3. **The kit stays apart from the theme repositories.** Put it in another folder, at another level or even on another drive.

For example, with `theme_dir` set to `/themes/{key}/www`:

```
projects/
  lightbolt-devkit/          ← the kit: compose.yml, engine/, .env, lightbolt/config.php
  lightbolt-themes/          ← THEMES= in .env
    sunrise/                 ← named after the theme's key
      www/                   ← the theme itself
```

Your organisation can agree on `theme_dir` and the themes folder for all its developers. An owner sets this under **Organisation → General → Developers**. A developer token from your profile then comes with a `config.php` and a `.env` line that already use them.

## Set it up once

1. **Download the dev kit.** You can do this in two places:
   - With **your own developer token**, go to your profile → **Developer tokens**. Next to the token there is a **Dev kit** button. Tick the sites you work on and choose **Download kit**. All sites in one kit must run the same engine version. The kit is already filled in with those sites, your organisation's `theme_dir` and note, and its themes folder. Steps 2 and 3 are then only copying files and pasting your token.
   - For **one site**, go to the site's **Domains and environments → Developer tokens → Dev kit**, and choose **Download dev kit** next to the environment.
   Unpack the kit in a folder of its own, **outside** the theme repository. The kit is made from the engine that the environment runs. It is available from engine 1.139.0. On an older engine, the screen tells you so.
2. **Copy `.env.example` to `.env`.** Set `THEMES` to the folder that **holds** your theme folders, not to a theme folder itself. Use forward slashes, also on Windows:
   ```
   THEMES=C:/projects/acme/lightbolt-themes
   ```
   That folder then contains `sunrise/`, named after the theme's key.
   Do you keep one folder per client, with the theme in `www` next to `design` and `docs`? Then keep `THEMES` at `lightbolt-themes`, and set `'theme_dir' => '/themes/{key}/www'` in step 3. This works from engine 1.141.0. On an older engine, point `THEMES` at the theme folder itself, and change `:/themes:ro` in `compose.yml` into `:/themes/sunrise:ro`.
3. **Copy `lightbolt/config.sample.php` to `lightbolt/config.php`.** Paste your developer token into `'token' => ''`. A comment above that line tells you which token to use. Leave the rest as it is:
   - `cms_url` is Lightbolt's address;
   - `dev` and `dev_hosts` hold the local address, with the site's ID and the environment;
   - `theme_dir` is where the engine looks for your theme. By default this is `/themes`, the folder from `.env`.
   **Several sites in one kit?** Then `dev_hosts` has one line per site. With your own token, the `token` at the top covers every line. With tokens for one site each, give each line its own token as a third element: `'othersite.localhost' => ['OTHERSITE1', 'staging', 'lbd_…'],`. This works from engine 1.141.0.
4. **Does the kit go into git?** Then rename `gitignore` to `.gitignore` first. It keeps `.env`, `config.php` and the local copy of the site out of git.

**`config.php` holds your token.** Never put it in a repository, a chat, a ticket or a screenshot. If it leaks, stop the token under Developer tokens and make a new one.

## Every day

Start the kit with this command, in the kit's folder:

```
docker compose up --build
```

To open a terminal in that folder on Windows, right-click an empty spot in the folder in Explorer and choose **Open in Terminal**. You can also type `cmd` in Explorer's address bar.

The very first time, Docker downloads PHP and builds its extensions. That takes a few minutes. After that it starts in seconds, and `docker compose up` is enough. The kit is ready when you see the line `Development Server (http://0.0.0.0:8080) started`.

Then open the local address with port 8080, for example `http://sunrise.localhost:8080/`.

- **The address.** Chrome, Edge and Firefox send every `*.localhost` name to your own computer. You do not need a hosts file. Do not use `.dev`, because browsers always force https on it.
- **The first page** fetches the site from Lightbolt. That takes a few seconds. After that, pages come from the local copy.
- **A change in your theme folder**, such as a template, CSS or an asset, shows on the next reload.
- **A change in Lightbolt** shows within about 15 seconds. A [signal](/md/docs/frontend/signals/) cannot reach your computer, so the engine asks Lightbolt itself whether anything changed. It asks at most every 15 seconds, and only fetches what changed.
- **You see what is published on that environment.** A draft never leaves Lightbolt. To see a change locally, publish it to staging first.
- **Changed `lightbolt/config.php`?** For example a new token, another site in `dev_hosts` or another `theme_dir`. Save the file and reload the page. The engine reads the file on every request, so you do not need to restart Docker.
- **When to restart.** Restart after a change in `.env`, `compose.yml` or the `Dockerfile`, and after you download a new kit. Run `docker compose down`, then `docker compose up --build`.
- **To stop**, press Ctrl+C or run `docker compose down`.
- **To start over** with a fresh copy of the site, run `docker compose down -v`, then `docker compose up --build`. From engine 1.142.0 the copy lives in Docker's own storage. On an older engine, delete `lightbolt/state/` and `httpdocs/_lb/` instead.
- **Fastest on Windows.** Keep the kit and your theme folder inside WSL2, for example in `\\wsl$\Ubuntu\home\you\…`. Then no files cross the slow bridge between Windows and Docker.

## What is different from a server

- There is no page cache and no https.
- A password on the environment still applies. Staging often has one, and the browser asks for it once.
- **Forms** are shown, but never sent. A form says *Not sent: this is a local copy*, because a developer token can only read. To test sending, use staging.
- **No reports, logs or checks** go to Lightbolt.
- **Previews** of drafts from the editor do not open in the kit. Use staging for those.
- **Live** is never reached. A developer token never reads live, and the engine refuses a developer token on a server.

## When something goes wrong

Look in two places first:

- the console where `docker compose up` runs, which shows PHP's errors;
- the engine's own log, `lightbolt/log/engine.log` in the kit's folder. On an engine before 1.142.0 it is `lightbolt/state/log/engine.log`.

Neither ever contains your token.

| What you see | What it means | What to do |
| --- | --- | --- |
| `Not configured` (503) | `lightbolt/config.php` is missing, or it is not valid PHP. | Copy it from `config.sample.php` again and paste your token. |
| `Not ready yet` (503) | The first copy of the site has not arrived yet. | Reload after a few seconds. If it stays, look in the log. |
| Log: `Could not resolve host`, or a 401 | Lightbolt's address is wrong, the token is wrong or expired, or there is no internet. | Check `cms_url`. If the token expired (after 180 days), make a new one. |
| A 401 after a new token | The token went into `config.sample.php` instead of `config.php`, or the file was not saved. | Paste it into `lightbolt/config.php`, save, and reload. You do not need to restart. |
| `Not found` (404) | The address in the browser is not the one in `dev_hosts`. | Use exactly that address, with `:8080`. |
| Log: `theme: not found` | The theme folder is not where the engine looks. From engine 1.141.0, the log line names the paths it tried. | Point `THEMES` to the folder that **holds** the theme folders. Name each theme folder after its key, or use `theme_dir` with `{key}`. |
| Log: `needs engine >=…, this is dev` | The kit is older than engine 1.141.0. | Download the kit again. |
| Port 8080 in use | Something else already runs on port 8080. | In `compose.yml`, change `"8080:8080"` to `"8081:8080"`, and open port 8081. |
| A change does not show | The browser shows a cached file, or you edit another folder. | Do a hard reload (Ctrl+Shift+R). Check that you edit the folder `THEMES` points to. |

**Asking for help?** Send the console output and the lines from `engine.log`. Never send `config.php` or `.env`.

## A new engine version

A kit holds one engine version. You find it in `engine/VERSION`. When the site's frontend gets a newer engine, download the kit again, so you test against what the site runs.

You do not need to keep track of this yourself. Lightbolt remembers which engine your kit was made from. When a site in it gets a newer engine, the bell says *A newer engine for your dev kit*. **Profile → Developer tokens** lists the sites and environments. A kit that sends `X-Lightbolt-Engine` with its calls also shows its version there.

From engine 1.142.0, the engine is built into the Docker image. So a new kit needs a fresh build:

1. Stop the old kit with `docker compose down`.
2. Unpack the new kit into a new folder. Or, if you reuse the old folder, delete `engine/` there first. Otherwise old files stay and end up in the image.
3. Copy your `.env` and `lightbolt/config.php` to the new folder. If you changed `compose.yml` yourself, make that change again.
4. Start with `docker compose up --build`.

You can delete the old `lightbolt/state/` and `httpdocs/_lb/` folders.

## From your computer to staging and live

A theme lives in its repository. See [Themes from Bitbucket or GitHub](/md/docs/themes/from-bitbucket/). This is the usual way:

1. Work on the `staging` branch, and check your work in the dev kit against staging's content.
2. Push to `staging`. The pipeline builds the theme and puts it on the site's staging environment. Check it there.
3. Merge into `main`. The same theme then goes live.
4. **Something wrong on live?** Choose the previous version under the site's **Theme → Theme version**. That works at once. Then revert the commit too, otherwise the next push puts the problem back.

Each push makes a new version under **Organisation → Themes → Versions**.

## Security, in short

- **A developer token** belongs on one computer, in the kit's `lightbolt/config.php`, and nowhere else. It never reads live.
- **A pipeline key** (`lbt_…`) belongs only in the pipeline's secured variables.
- **The dev kit** never holds a token, a key or another client's theme. If someone forwards a kit, it opens no site by itself.
- **Never switch `dev` on** on a server.
- **Themes contain PHP code.** That is why your themes only run on your agency's own frontends.

See also [Tokens](/md/docs/start/tokens/).

*Also called: local setup, dev environment, running the frontend locally, docker compose.*

Last changed 26 November 2026
