Getting Started
Database CLI
Run migrations, seeding, rollbacks, and backups from the command line. Included in strata/database.
Note: Strata doesn't ship with a php strata command yet. All CLI tools live in /bin/ and are provided by individual modules. Run all commands from your project root.
On this page
Migration Commands
Run from your project root:
php bin/migrate.php # Apply all new migrations
php bin/rollback.php # Roll back the last migration
php bin/rollback.php 2 # Roll back last 2 migrations
php bin/migration_status.php # Show applied/pending migrations
php bin/create_migration.php AddUsersTable # Scaffold new migration
Scaffolding output:
database/migrations/20260505143000_AddUsersTable.php
database/migrations/20260505143000_AddUsersTable.down.php
Migration locking prevents concurrent runs. Each migration tracks applied_by and applied_at. If a migration crashes, clear stuck locks with: php bin/migrate.php --unlock
Seeding Commands
php bin/seed.php # Run all seeds in seeds/
php bin/seed.php --down # Remove seeded data
See Database → Seeding for how to write seeders.
Backup Command
Create a full database dump. Requires mysqldump in your PATH for MySQL. Falls back to PDO for other drivers.
php bin/backup_db.php # Dumps to storage/backups/db-YYYY-MM-DD.sql
php bin/restore.php --latest # Restores most recent backup
Backups are stored in storage/backups/. Add that directory to .gitignore.
Manual restore example:
mysql -u username -p database_name < storage/backups/db-2026-05-05.sql
Dev Server
Strata has no built-in server command. Use PHP's built-in server:
php -S localhost:8000 -t public_html router.php
Omit router.php if your project doesn't use a front controller. For Apache/Nginx, point your vhost to /public_html.
Common Errors
| Error | Fix |
|---|---|
| Migration table not found | Run php bin/migrate.php install to create the migrations table first. |
| mysqldump: command not found | Install MySQL client tools or ensure mysqldump is in your PATH. Strata will use PDO fallback. |
| Migration is locked | Another process is running or crashed. Wait 300s or run php bin/migrate.php --unlock. |
Future: strata/cli
A strata/cli module with php strata make:controller is planned but not released. Track progress or request features on GitHub Issues. For now, create controllers/models manually or use your IDE's scaffolding.