CLI Tooling
CLI Tooling
The zero executable provides a light command-line interface for common development tasks.
Installation
The script ships with the repository; ensure it is executable:
chmod +x zeroCommands
Serve the Application
php zero serve [--host=127.0.0.1] [--port=8000] [--root=public] [--watch] [--franken] [--swolee]--host,--port, and--rootmirror PHP's built-in server options (defaults fall back to theHOST,PORT, andDOCROOTenvironment variables when present).--watchenables a basic file watcher that restarts the server on changes.--frankenand--swoleeexpose experimental server backends.
Generate a Controller
php zero make:controller PostsControllerCreates app/controllers/PostsController.php with a simple index action. Append --force to overwrite an existing file. The generator will add the Controller suffix automatically if it is not present.
Generate a Service
php zero make:service Billing/InvoiceCreates app/services/Billing/Invoice.php, keeping the provided name intact and creating nested directories on demand. Use --force to overwrite an existing class. Both forward slashes and backslashes are accepted in the name.
Generate a Helper
php zero make:helper randomTextCreates app/helpers/RandomText.php with a helper skeleton that exposes a default signature derived from the class name. Register the helper in app/helpers/Helper.php so it becomes available globally (for example, random_text(10)). Use --force to overwrite an existing helper.
Generate a Console Command
php zero make:command HealthCheck --signature=app:healthCreates app/console/Commands/HealthCheck.php implementing the CommandInterface. The generator also ensures app/console/Commands/Command.php exists and appends the new command to its registration list so it is immediately available to the CLI. Provide --description="..." to customise the help text and --force to overwrite an existing command class.
Generate a Model
php zero make:model PostCreates app/models/Post.php extending the base Zero\Lib\Model. Use --force to regenerate an existing model class.
Generate a Migration
php zero make:migration create_users_tableCreates a timestamped file in database/migrations. Each migration returns an anonymous class that extends Zero\Lib\DB\Migration with up() and down() methods.
Run outstanding migrations with:
php zero migrateRollback the latest batch:
php zero migrate:rollback [steps]Reset the database by rolling back every batch and rerunning all migrations:
php zero migrate:refreshDrop every table (ignoring individual down() methods) before running migrations from scratch:
php zero migrate:freshMigrations leverage the lightweight schema builder:
use Zero\Lib\DB\Schema;
use Zero\Lib\DB\Blueprint;
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});You can chain fluent modifiers on column definitions (e.g., $table->string('email')->nullable()->unique();).
Pass a number to migrate:rollback to reverse multiple batches, e.g. php zero migrate:rollback 2.
Modify tables with Schema::table:
Schema::table('users', function (Blueprint $table) {
$table->string('nickname', 50)->nullable();
$table->dropColumn('legacy_field');
});Generate a Seeder
php zero make:seeder UsersTableSeederSeeders extend Zero\Lib\DB\Seeder and live in database/seeders. Execute a seeder with:
php zero db:seed Database\\Seeders\\UsersTableSeederGenerate a Middleware
php zero make:middleware EnsureAdminCreates app/middlewares/EnsureAdminMiddleware.php with a handle() stub ready for authentication or authorization logic. Use --force to overwrite an existing file.
Link Storage
php zero storage:linkCreates symbolic links defined in config/storage.php (by default linking public/storage to the public disk). The command skips existing links and reports missing targets.
Inspect Registered Routes
php zero route:listBootstraps routes/web.php and prints a table with the HTTP method, URI, route name (when available), controller action, and attached middleware stack. Use it to confirm route bindings after adding groups, name prefixes, or new controllers.
Update to Latest Release
- Fetches a JSON manifest from the URL configured via
UPDATE_MANIFEST_URL. - Displays the target version and files that will be updated before applying changes.
- Downloads each file securely (with optional SHA-256 verification when provided in the manifest).
- Prompts for confirmation unless
--yesis supplied.
After updating, review release notes, clear caches, and run migrations as needed.
Customising Stubs
Stub templates live under core/templates. Adjust controller.tmpl, service.tmpl, or model.tmpl (or add new files) to change the generated skeletons.
Extending the CLI
Commands are dispatched from the zero script. New subcommands can be added by extending the switch statement and creating helper functions to encapsulate behaviour.