Zap
Documentation / Workflow

CLI

Zap’s command-line interface is the project-root console script. Run commands from the root of your application with PHP:

php console

The command lists available operations. Add a command name and any required arguments to run it.

Generate app files

Run generators from the project root. Names can include subdirectories.

php console make:controller Admin/UserController
php console make:model User
 php console make:migration create_users_table

The controller generator creates a controller under app/Controllers; models go under app/Models, and migration files go under migrations. Use --help with a command for its usage when supported.

Environment and keys

php console generate --env
php console generate --key

generate --env creates .env from the project stub. If a file already exists, the command asks before overwriting it. generate --key prints a new application key; copy it to APP_KEY in your private .env file.

Database migrations

Creating a migration only writes a timestamped PHP file under migrations/; it does not define your columns or run the migration. Open the generated file and add the schema you need before migrating.

For example, php console make:migration create_users_table selects the create-table stub. It already imports Database and Blueprint, defines the table name, and provides up() and down(). The create stub adds only an id column by default; add the remaining fields inside its existing callback:

public function up(Database $db): void
{
 $db->schema()->create($this->table, function (Blueprint $table) {
 $table->id();
 $table->string('name');
 $table->string('email');
 $table->unique('email');
 $table->timestamps();
 });
}

$db->schema() provides the Schema API, and its callback receives the Blueprint used to declare columns and indexes. The generated down() for a create-table migration drops that table. Add or remove fields in the appropriate up() and down() methods before running pending migrations.

Then check status and apply the completed migration:

php console migrate:status
php console migrate:start
 php console migrate:status
 php console migrate:rollback --last

migrate:start runs pending migrations. To undo changes, migrate:rollback reverts the latest batch with --last, or all batches with --all. The destructive migrate:fresh command drops all tables and reruns migrations:

php console migrate:fresh
Warning: migrate:fresh deletes existing database tables. Back up important data and verify the configured database before running it.

Routes, caches, and maintenance

php console route:list
php console cache:routes
php console cache:controllers
php console clear cache
php console clear views
php console clear all

Use route:list to inspect registered web routes. Cache commands prepare production route or controller caches. Clear cached data after changing routes or controllers during development. The clear command also supports logs, sessions, and views; clear all removes logs, sessions, and cache resources.

For a local web server, use the router script from the project root: php -S localhost:8000 dev-server.php.