Command Line
Mission Control
The Zenith CLI serves as your starship's command bridge — a clean, menu-driven interface for framework tasks with extensible command classes you can pilot.
Built for Command Excellence
Every command interface is engineered for clarity, efficiency, and extensibility — giving you full control over your development workflow.
Menu-Driven Interface
Clean, numbered menu system with confirmation prompts for safe command execution.
Auto-Discovery
Automatically discovers and lists PHP command classes from Zenith/Commands directory.
Extensible Commands
Drop PHP classes into Commands directory and they appear automatically with readable descriptions.
Interactive Flow
Execute commands and optionally return to main menu for continuous workflow management.
Installation & Quick Start
Run the CLI from your project root to access all available commands. No setup required — just execute and explore.
Using PHP
Execute directly with PHP interpreterphp zenith-cli.php
Make Executable (Unix)
Direct execution on Unix systemschmod +x zenith-cli.php
./zenith-cli.php
CLI Interface Preview
$ php zenith-cli.php
███████╗███████╗███╗ ██╗██╗████████╗██╗ ██╗ ██████╗██╗ ██╗
╚══███╔╝██╔════╝████╗ ██║██║╚══██╔══╝██║ ██║ ██╔════╝██║ ██║
███╔╝ █████╗ ██╔██╗ ██║██║ ██║ ███████║ ██║ ██║ ██║
███╔╝ ██╔══╝ ██║╚██╗██║██║ ██║ ██╔══██║ ██║ ██║ ██║
███████╗███████╗██║ ╚████║██║ ██║ ██║ ██║ ╚██████╗███████╗██║
╚══════╝╚══════╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝
Available Commands:
[1] ConfigureStorage Configure storage settings
[2] CreateModel Create a new model class
[3] InitDatabase Initialize database structure
[0] Exit
[?] Enter command number to execute [0]: 1
You selected: ConfigureStorage
[?] Do you want to execute this command? (y/n) [y]: y
Executing command...
Menu-Driven Command Execution
Choose a command, confirm execution, and optionally return to the main menu. Commands with a run() method are preferred for consistent interface.
Interactive Flow
Complete command execution cycle$ php zenith-cli.php
Available Commands:
[1] CreateModel Create a new model class
[2] InitDatabase Initialize database structure
[0] Exit
[?] Enter command number to execute [0]: 1
You selected: CreateModel
[?] Do you want to execute this command? (y/n) [y]: y
Executing command...
Model created successfully!
Command execution completed!
[?] Return to main menu? (y/n) [y]: y
Discovery Mechanics
How commands are found and executed// 1. CLI scans Zenith/Commands/*.php files
// 2. Attempts to instantiate Zenith\Commands\ClassName
// 3. If class has run() method, calls it
// 4. Otherwise executes file directly
// 5. Extracts description from class docblock
class CreateModel {
public function run(): void {
// Your command logic here
echo "Creating model...\n";
}
}
Extend Your Command Arsenal
Drop a PHP file into Zenith/Commands and it appears automatically in the CLI menu with a readable name and description extracted from your code.
Create PHP Class
Create a new PHP file in Zenith/Commands with a descriptive class name.
class MyCommand
Add run() Method
Implement the run() method with your command logic — this is called when executed.
public function run(): void {
// Your logic here
}
Document Purpose
Add a docblock comment — the first line becomes the command description in the menu.
/**
* My Custom Command
* Description here
*/
Complete Command Class Example
A real-world implementation showing best practices<?php
namespace Zenith\Commands;
/**
* Create Model
* Creates a new model scaffold in Zenith/Models directory
*/
class CreateModel {
public function run(): void {
// Prompt for model name
echo "Enter model name: ";
$name = trim(fgets(STDIN));
if ($name === '') {
echo "Model name is required.\n";
return;
}
// Clean the class name
$class = preg_replace('/[^A-Za-z0-9_]/', '', $name);
$file = __DIR__ . '/../Models/' . $class . '.php';
// Check if model already exists
if (file_exists($file)) {
echo "Model already exists: {$file}\n";
return;
}
// Generate model template
$template = "<?php\nnamespace Zenith\\Models;\n\nuse Zenith\\Core\\Model;\n\n";
$template .= "class {$class} extends Model {\n";
$template .= " protected static string \$table = '" . strtolower($class) . "s';\n";
$template .= " protected static string \$primaryKey = 'ID';\n";
$template .= "}\n";
// Ensure directory exists
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0777, true);
}
// Write the model file
file_put_contents($file, $template);
echo "✓ Model created: {$file}\n";
}
}
System Details & Notes
Understanding how the CLI discovers and executes commands helps you build more effective tools for your development workflow.
Description Extraction
How command descriptions are determinedThe CLI extracts descriptions using this priority:
- First line of class docblock comment
- Class name converted from CamelCase to readable format
- Filename as last resort
Important Notes
Rules and limitations to keep in mind- Files must be in
Zenith/Commandsand end with.php - Classes with
run()method are instantiated and called - Files without
run()method are executed directly - CreateModel is hidden if
Zenith/Modelsdirectory doesn't exist