Local Development

Getting started

  1. Clone the project from GitHub.
  2. Get the .env file from Keeper and place it inside the src/ folder.
  3. From src/, install dependencies:
    composer install
    npm install
    
  4. Return to the project root (cd ../) and bring up the containers:
    docker-compose -f docker-compose-mk-dev.yml up --build
    

    Use --build to refresh the container image after dependency or Dockerfile changes.

Docker Compose environments

The repo ships several compose files for different scenarios. Each uses the Dockerfile.dev image and mounts ./src into the container.

FileContainer nameHost portNotes
docker-compose.ymlpedalheads-public-api9000Default dev stack
docker-compose-mk-dev.ymlpedalheads-public-api-mk-dev8000Martin’s dev server
docker-compose-2025-schema.ymlpedalheads-public-api-2025-schema8000Points at the 2025 schema database
docker-compose-prod.ymlpedalheads-public-api-prod9090Production-style image (Dockerfile)

:::warning Always make sure the container name you target in commands matches the container you actually have running. :::

Common commands

Open a shell inside the running container:

docker exec -it pedalheads-public-api /bin/bash
# or, for the mk-dev stack:
docker exec -it pedalheads-public-api-mk-dev /bin/bash

Queue workers

When working on a queued job, restart the queue workers after code changes:

docker compose exec pedalheads-public-api php artisan queue:restart

Migrations

:::danger The API does not own the database schema Migrations are run from the Cadence / Velo Admin app to keep the shared schema clean. Run schema changes there before releasing the API so the API has every DB update it depends on. The commands below are for local/dev use only. :::

# Create a migration that adds a column
php artisan make:migration add_columnname_to_tablename_table --table=tablename

# Run / refresh / rollback migrations (dev)
docker compose exec pedalheads-public-api php artisan migrate
docker compose exec pedalheads-public-api php artisan migrate:refresh
docker compose exec pedalheads-public-api php artisan migrate:rollback

Clearing cache

php artisan cache:clear

Testing

# Create a test
php artisan make:test UserTest

# Run the suite
php artisan test

Debugging with Telescope (DEV ONLY)

Laravel Telescope can be enabled in development for request/query inspection.

TELESCOPE_ENABLED=true
ASSET_URL="${APP_URL}"

:::warning Only enable Telescope in development — never in production. :::

Testing CORS from the browser console

const userAction = async () => {
  const response = await fetch(
    'https://api.pedalheads.com/api/allocations/23221'
  );
  const myJson = await response.json();
  console.log(myJson);
};
userAction();