Celestial CLI
Introduction
Celestial is the command-line interface included with Slenix. Celestial exists at the root of your application as the celestial script and provides a number of helpful commands that can assist you while you build your application. To view a list of all available Celestial commands, you may use the help command:
php celestial helpEvery command also includes a brief description. To see the current version of Celestial:
php celestial versionWriting and Running Commands
Starting the Development Server
Celestial includes a built-in development server powered by PHP's native server. To start it, run the serve command from the root of your application:
php celestial serveThe development server will be accessible at http://127.0.0.1:8080 by default. You may specify a custom port by passing it as an argument:
php celestial serve 9000This will serve your application at http://127.0.0.1:9000. To stop the server, press Ctrl+C in your terminal.
Note: Celestial serves files from the
public/directory. If thepublic/directory does not exist, Celestial will attempt to create it automatically.
Valid port numbers range from 1 to 65535. Passing a port outside this range will result in an error.
Generating Application Keys
Slenix uses an application key for encryption and security. This key is stored as APP_KEY in your .env file and should always be set before deploying to production.
To generate and save a new application key:
php celestial key:generateThis command generates a cryptographically secure 32-byte key, encodes it as base64 with a base64: prefix, and writes it directly to your .env file. If the .env file does not exist, Celestial will attempt to create it by copying .env.example.
[✔] APP_KEY generated and saved to .env
[ℹ] Key: base64:i4OjqaSH96ZEoCkKRfuIyBYZCj6zyg8fS/WnzlLbkZ4=You should regenerate the application key any time you suspect your existing key has been compromised. Note that changing the key will invalidate all encrypted data and active sessions.
Generating Controllers
To generate a new controller class, use the make:controller command:
php celestial make:controller UserThis will create a new file at app/Controllers/UserController.php with a minimal class stub ready to use:
namespace App\Controllers;
use Slenix\Http\Request;
use Slenix\Http\Response;
class UserController
{
public function index(Request $request, Response $response)
{
// Your application logic
}
}You can specify a name in any case — Celestial will automatically capitalize the first letter. The Controller suffix is not required in the command argument:
php celestial make:controller UserProfile
# Creates: app/Controllers/UserProfileController.php ← not added, name preservedNote: If a controller with the same name already exists, Celestial will display an error and will not overwrite it.
Generating Models
To generate a new model class, use the make:model command:
php celestial make:model PostThis will create app/Models/Post.php with a stub that extends Slenix\Supports\Database\Model. The table name is automatically inferred from the model name using snake_case with a plural suffix:
namespace App\Models;
use Slenix\Supports\Database\Model;
class Post extends Model
{
protected string $table = 'posts';
protected string $primaryKey = 'id';
protected array $fillable = [];
}For multi-word model names, the table name is derived accordingly:
| Model Name | Inferred Table |
|---|---|
User | users |
BlogPost | blog_posts |
OrderItem | order_items |
ProductCategory | product_categorys |
Note: For irregular plurals (e.g.
Person→people), set the$tableproperty manually inside the generated model.
Generating Middleware
To generate a new middleware class, use the make:middleware command:
php celestial make:middleware EnsureEmailIsVerifiedThis will create app/Middlewares/EnsureEmailIsVerifiedMiddleware.php. If the name you provide does not already end in Middleware, Celestial appends it automatically:
php celestial make:middleware Auth
# Creates: app/Middlewares/AuthMiddleware.phpThe generated class implements the Slenix\Http\Middlewares\Middleware interface and includes a ready-to-use handle stub:
namespace App\Middlewares;
use Slenix\Http\Request;
use Slenix\Http\Response;
use Slenix\Http\Middlewares\Middleware;
class AuthMiddleware implements Middleware
{
public function handle(Request $request, Response $response, callable $next): mixed
{
// Middleware logic here
return $next($request, $response);
}
}Listing Routes
To inspect all routes registered in your application, use the route:list command:
php celestial route:listCelestial loads routes/web.php and prints a formatted table showing the HTTP method, URI, handler, and route name for every registered route:
--------------------------------------------------------------------------------
METHOD URI HANDLER NAME
--------------------------------------------------------------------------------
GET / HomeController@index home
GET /login AuthController@loginShow login.show
POST /login AuthController@login login
GET /register AuthController@register.. register.show
POST /register AuthController@register register
GET /dashboard DashboardController@index home.show
[auth]
--------------------------------------------------------------------------------
[✔] Total: 6 routesMiddleware assigned to a route is displayed on the line below the route entry, enclosed in square brackets.
Clearing the View Cache
Luna compiles your .luna.php templates into plain PHP and caches them in storage/views/. When deploying new templates, you may want to clear the compiled cache:
php celestial viewThis calls Luna::clearCache() internally, deleting all .php files in storage/views/. The next request to any view will trigger a fresh compilation.
Tip: In development, set
APP_DEBUG=truein your.envfile. This causes Luna to bypass the cache entirely, so you never need to clear it manually during development.
Terminal Output Reference
Celestial uses colored, prefixed output to help you distinguish between different types of messages at a glance:
| Symbol | Color | Method | Meaning |
|---|---|---|---|
[ℹ] | Cyan | Command::info() | Informational message |
[✔] | Green | Command::success() | Operation completed successfully |
[!] | Yellow | Command::warning() | Non-critical warning |
[✗] | Red | Command::error() | Error or failed operation |
Command Reference
Below is a complete reference of all commands available in Celestial:
| Command | Arguments | Description |
|---|---|---|
php celestial help | — | Display the help screen with all available commands |
php celestial version | — | Display the current Celestial CLI version |
php celestial serve | [port] | Start the local development server (default port: 8080) |
php celestial key:generate | — | Generate and save a new APP_KEY to .env |
php celestial make:controller | <name> | Generate a new controller class in app/Controllers/ |
php celestial make:model | <name> | Generate a new model class in app/Models/ |
php celestial make:middleware | <name> | Generate a new middleware class in app/Middlewares/ |
php celestial route:list | — | Display all registered application routes |
php celestial view | — | Clear the compiled Luna template cache |
Exit Codes
Celestial uses standard POSIX exit codes:
| Code | Meaning |
|---|---|
0 | Success |
1 | General error (unknown command, missing argument, file write failure, etc.) |
When an unrecoverable error occurs, Celestial prints a descriptive message in red and exits with code 1:
[✗] Error: Controller 'UserController' already exists at app/Controllers/UserController.php.