Local setup
About 892 wordsAbout 3 min
The skeleton (spora-ai/spora) ships a working local dev environment. The only thing you need to install is PHP 8.4+, Composer, and — only if you are working on the admin SPA — Node.js and npm.
Prerequisites
- PHP 8.4.1+ with
curl,dom,fileinfo,iconv,json,mbstring,openssl,pdo,pdo_mysql,pdo_sqlite,simplexml,sodiumandzip - Composer (latest 2.x)
- Node.js 20.19+ or 22.12+ and npm — only for working on the admin SPA in
spora-frontend; the skeleton ships the prebuilt UI, so a plain install needs neither
Install the skeleton
composer create-project spora-ai/spora my-spora
cd my-spora
composer installcomposer install also installs spora-ai/spora-frontend (the prebuilt admin UI) and spora-ai/installer (the Composer plugin that routes spora-plugin and spora-frontend packages to the right directories).
Initialise the database
cp .env.example .env
# Edit .env: set SPORA_SECRET_KEY (32-byte base64), leave SPORA_DB_DRIVER=sqlite
php bin/spora spora:install # creates schema (idempotent)
php bin/spora db:seed # creates a sample admin userspora:install is idempotent — re-run it after any new migration ships. It also ensures storage/secret.key exists (generating one if the file is missing) and points config.php’s key_path at it, so the SPORA_SECRET_KEY line in .env is optional — but note that the environment variable takes precedence at runtime, and the two must not disagree: encrypt with one and read with the other and every stored credential becomes undecryptable.
db:seed is insert-only for admin and agent rows — it never patches an existing admin row, so it cannot resurrect a deleted admin or overwrite an operator-rename/demote. If you need to promote an existing admin row (e.g. it’s stuck at verified=0 after an upgrade), use php bin/spora db:repair-admin instead.
In addition, db:seed reconciles mail templates against email-templates/: any YAML that is missing from the DB is inserted, and operator-customised templates are preserved (no force). Run php bin/spora mail:templates:sync interactively (or php bin/spora mail:templates:sync --force) if you want to overwrite drifted rows.
To generate a secret key yourself:
php -r "echo base64_encode(random_bytes(32));"Start the dev server
composer devThis starts the PHP built-in server:
- PHP —
php -S 127.0.0.1:8080 -t public public/index.php
The site is at http://localhost:8080.
The admin SPA ships prebuilt, so there is no Vite dev server in this workflow. To work on the SPA itself — with HMR — clone spora-frontend and run it there; that repository is a separate checkout from the framework.
For a production-like local server without the PHP dev server, use the Docker single-container path or the Local — PHP / Ollama / LM Studio(Open in new window) path.
Run tests
composer test # Backend (Pest)
./vendor/bin/pest --filter="pattern" # Filter tests by nameThe skeleton ships no tests of its own — its tests/ directory is empty. The framework’s suite lives in spora-ai/spora-core, where the scripts are composer test:parallel, composer test:coverage, composer analyse and composer format.
Frontend unit tests live with the SPA, in spora-frontend — clone it and work in its own checkout:
git clone https://github.com/spora-ai/spora-frontend.git
cd /path/to/spora-frontend
npm test # All Vitest unit tests
npm run test:watch # Watch modeEnd-to-end (E2E) tests are not currently wired up — there is no Playwright dependency and no tests/e2e/ directory. The two repositories’ CI pipelines run Pest and Vitest separately, not E2E.
Database
- SQLite at
storage/database.sqlite(the default, zero-config) - Migrations —
php bin/spora spora:install(idempotent; safe to re-run) - Seed —
php bin/spora db:seed(inserts missing admin + sample agent; also reconciles mail templates againstemail-templates/, preserving operator-customised rows) - Reset —
php bin/spora db:reset --force(wipes the SQLite file or drops + recreates the MySQL DB)
To use MySQL instead, edit .env:
SPORA_DB_DRIVER=mysql
SPORA_DB_HOST=127.0.0.1
SPORA_DB_PORT=3306
SPORA_DB_NAME=spora
SPORA_DB_USER=spora
SPORA_DB_PASSWORD=your-passwordThen re-run php bin/spora spora:install to apply the migrations to the new DB.
Storage
storage/ directory contents after a first run:
database.sqlite— application databasesecret.key— libsodium master key (32 bytes binary)spora.log— application logs (PSR-3, Monolog)spora-worker.lock— single-instance worker lock.schema_stamp— migration stamp cache.plugins_stamp,.plugins_stamp.cache.json— plugin loader caches.spora_plugin_catalog.json— on-disk Packagist catalogue cache
storage/ is intentionally not copied into the Docker image (it would risk shipping the SQLite DB and secret.key). For backup strategy, see Backups.
Environment variables
Two are operationally important in dev:
SPORA_WORKER_RUNTIME_MODE— defaults toserver(inspora-ai/spora). The local-dev path runscomposer dev, which is the PHP built-in server — pair it withphp bin/spora worker:run --daemonin a second terminal to drain the queue, or setSPORA_WORKER_RUNTIME_MODE=clientif you only want browser-driven ticks (see Deployment modes).SPORA_APP_ENV—production(the registry default),development, orlocal. The skeleton’s.env.exampleshipsdevelopment. Affects error reporting, the debug block in 500 responses, and login throttling.
For the full env-var reference, see Environment variables.
What’s next
- Project structure — where things live in
spora-core - Stack — every Composer dependency and its role
- How to add a tool — the canonical “Hello, Tool” walkthrough