Docs Contributing
Development setup
Run Snapsbrew on your computer to develop and test a change.
This page tells you how to run Snapsbrew on your computer for development. To run an instance for real use, read Install with Docker.
Requirements
- PHP 8.3 or 8.4, with the
gd,intl,exifandbcmathextensions - Composer
- Node 22 and npm
- Chrome or Chromium, for the
browsershotrenderer
SQLite is the default database for development. You do not need MySQL or Redis.
Install the app
-
Clone the app repository and go into its folder.
-
Install the PHP packages:
composer install -
Install the Node packages:
npm install -
Copy the example environment file:
cp .env.example .env -
Generate the app key:
php artisan key:generate -
Create the SQLite database file:
touch database/database.sqlite -
Run the migrations:
php artisan migrate -
Create the Passport keys and the storage link:
php artisan snapsbrew:install --prepare -
Build the front-end assets:
npm run build -
Start the web server:
php artisan serve
Create the owner account
While the instance has no account, /, /login and /register redirect to /setup. The setup page asks for a setup token.
-
Get the setup URL with the token:
php artisan snapsbrew:setup-url -
Open the URL and create the owner account.
To create the owner in the terminal instead, run php artisan snapsbrew:install without --prepare.
Work on the front end
To rebuild the assets each time that you save a file, start the Vite development server:
npm run dev
Keep php artisan serve open in a second terminal.
Queues
.env.example sets QUEUE_CONNECTION=sync. With sync, each job runs in the request, so you do not need a queue worker.
To test the queues as production runs them, set QUEUE_CONNECTION=redis and start Horizon:
php artisan horizon
Horizon needs Redis. Read Queues and Horizon.
The renderer
The default renderer for development is browsershot. It starts Chrome through Node and Puppeteer for each render.
- If Puppeteer did not download a Chrome, set
PUPPETEER_EXECUTABLE_PATHto the path of a local Chrome. Puppeteer reads this variable. The app code does not read it. - If Node is not at
/usr/local/bin/node, setBROWSERSHOT_NODE_PATH. - If npm is not at
/usr/local/bin/npm, setBROWSERSHOT_NPM_PATH.
To use Browserless instead:
-
Generate a token:
export BROWSERLESS_TOKEN=$(openssl rand -hex 24) -
Start the Browserless container:
docker compose -f deploy/browserless/docker-compose.yml up -d -
Set these values in
.env:RENDER_DRIVER=browserless BROWSERLESS_URL=http://127.0.0.1:3000 BROWSERLESS_TOKEN=<the same token>
Browserless loads the fonts and images of a snap from its own container. It cannot load a file from a URL that it cannot reach. Read Rendering.
Test the MCP server
To open the MCP Inspector against the local server, run:
php artisan mcp:inspector mcp
Before you open a pull request
- Run the tests, the code style check and the front-end build. Read Testing.
- Read the
CONTRIBUTING.mdfile of the app repository. - If the change is large, open an issue first.