# Production table QR configuration

`Encrypter needs a starter key.` means CodeIgniter received an empty encryption key. The table QR page uses `encryption.key` to decrypt the stored table token for reprinting. Café ERP also uses it when generating a new code. The scanned menu URL uses a hash of the token, so existing printed codes can still open the menu while the encryption key is unavailable.

1. Set `CI_ENVIRONMENT = production` in the server environment or in the private `.env` beside `spark`. Use the correct HTTPS `app.baseURL` and serve the application from `public/`. Verify that the web PHP process is reading the intended environment and remove any conflicting environment overrides or duplicate key assignments.
2. If the production database already contains encrypted table codes, restore its original `encryption.key` from the deployment configuration or backup. Copy the value exactly, including any `hex2bin:` or `base64:` prefix. Keep the key private and backed up with the database.
3. For a deployment with no previously encrypted data, run `php spark cafe:qr-key` from the project root. The command requires a writable `.env` and initializes a key without displaying it.
4. Reload the PHP service if your host injects environment variables at startup. If CodeIgniter configuration caching was enabled with `spark optimize`, rebuild the cache after updating the environment. In **Tables**, open an existing QR page and verify that the reprinted URL works from a phone.

If the original key cannot be recovered, configure a new key and replace each affected code from **Tables**. Existing paper codes for a table stop working as soon as that table's code is replaced. If the original key is still available during a planned rotation, CodeIgniter supports keeping it in `encryption.previousKeys`.
