CLI Tool
LavaLust includes a built-in command-line interface (CLI) tool called lava
for scaffolding application files, managing cache, inspecting routes, and running
the development server. It eliminates the need to manually create boilerplate files.
The lava script lives in your project root and is executed via PHP from your terminal.
php lava <command> [argument] [--flag=value]
Note
The lava script is CLI-only. Accessing it through a web browser is blocked
automatically.
Available Commands
Commands are grouped by function.
Server
Command |
Description |
|---|---|
|
Start the PHP built-in development server (default port: |
Cache
Command |
Description |
|---|---|
|
Delete all files in |
Makers
Command |
Description |
|---|---|
|
Generates a controller class in |
|
Generates a model class in |
|
Generates a middleware class in |
|
Generates a helper file in |
|
Generates a library class in |
|
Generates a view file in |
|
Generates a language file in |
|
Generates a config file in |
|
Generates a custom CLI command class in |
Utilities
Command |
Description |
|---|---|
|
Display all registered routes parsed from |
|
Generate a new 64-character |
|
Display a summary of the current |
Development Server
run [port]
Starts the PHP built-in development server pointing to the public/ directory.
# Start on the default port 3000
php lava serve
# Start on a custom port (positional)
php lava serve 8080
# Start on a custom port (flag)
php lava serve --port=8080
Output:
Starting LavaLust development server...
Server running on: http://127.0.0.1:3000
Press Ctrl+C to stop the server.
Note
The server requires a public/ directory in the project root.
An error is shown if it cannot be found.
Note
You can also use php lava run command to start the server.
Results are the same with php lava serve.
Cache Management
cache:clear
Deletes all files and empty subdirectories inside runtime/cache/.
php lava cache:clear
Output:
Cache cleared! 14 file(s) removed from runtime/cache.
Note
The cache directory is runtime/cache/ relative to the project root
(not app/cache/). An error is shown if the directory does not exist.
Generating Files
All make:* commands accept a name argument. Forward slashes (/) create
subdirectories inside the target folder. Generated files include boilerplate
code and will never overwrite an existing file.
make:controller
Creates a controller class extending BaseController in app/Controllers/.
php lava make:controller Dashboard
php lava make:controller Admin/UserController
Generated file (app/Controllers/Dashboard.php):
<?php
defined('PREVENT_DIRECT_ACCESS') OR exit('No direct script access allowed');
/**
* Controller: Dashboard
*
* Automatically generated via CLI.
*/
class Dashboard extends BaseController {
public function __construct()
{
parent::__construct();
}
}
make:model
Creates a model class extending Model in app/Models/. Includes default
$table, $primary_key, $fillable, and $guarded properties.
php lava make:model UserModel
php lava make:model Blog/PostModel
Generated file (app/Models/UserModel.php):
<?php
defined('PREVENT_DIRECT_ACCESS') OR exit('No direct script access allowed');
/**
* Model: UserModel
*
* Automatically generated via CLI.
*/
class UserModel extends Model {
protected $table = '';
protected $primary_key = 'id';
protected $fillable = [];
protected $guarded = ['id'];
public function __construct()
{
parent::__construct();
}
}
make:middleware
Creates a middleware class in app/middlewares/. The class name is automatically
suffixed with Middleware.
php lava make:middleware Auth
php lava make:middleware Admin/Role
Generated file (app/middlewares/AuthMiddleware.php):
<?php
defined('PREVENT_DIRECT_ACCESS') OR exit('No direct script access allowed');
/**
* Middleware: AuthMiddleware
*
* Automatically generated via CLI.
*/
class AuthMiddleware
{
/**
* Handle the incoming request
*
* @param Closure $next
* @return mixed
*/
public function handle(Closure $next)
{
// TODO: Add your middleware logic here
return $next();
}
}
Note
After generating a middleware, register it in app/config/middleware.php
before attaching it to routes.
make:helper
Creates a helper file with a starter function in app/helpers/.
The filename is suffixed with _helper.php automatically.
php lava make:helper text
php lava make:helper String/format
Generated file (app/helpers/text_helper.php):
<?php
defined('PREVENT_DIRECT_ACCESS') OR exit('No direct script access allowed');
/**
* Helper: text_helper.php
*
* Automatically generated via CLI.
*/
function text_helper()
{
// Your helper logic here
}
make:library
Creates a standalone library class in app/Libraries/.
php lava make:library PDF
php lava make:library Payment/Stripe
Generated file (app/Libraries/PDF.php):
<?php
defined('PREVENT_DIRECT_ACCESS') OR exit('No direct script access allowed');
/**
* Library: PDF
*
* Automatically generated via CLI.
*/
class PDF {
public function __construct()
{
// Library initialized
}
}
make:view
Creates an HTML view file in app/views/.
php lava make:view homepage
php lava make:view user/profile
Generated file (app/views/homepage.php):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Homepage</title>
</head>
<body>
<h1>Welcome to Homepage View</h1>
</body>
</html>
make:language
Creates a language file in app/language/.
php lava make:language en-US
php lava make:language tag-PH
Generated file (app/language/en-US.php):
<?php
return array(
/**
* Other strings to be translated here
*/
'welcome' => 'Hello {username} {type}',
);
make:config
Creates a blank configuration file in app/config/.
php lava make:config auth
php lava make:config payment
Generated file (app/config/auth.php):
<?php
defined('PREVENT_DIRECT_ACCESS') OR exit('No direct script access allowed');
/**
* Config: auth
*
* Automatically generated via CLI.
*/
// Add your configuration here
make:command
Creates a custom CLI command class in app/commands/. After generating,
register the command in the lava script using register_command().
php lava make:command SendEmails
php lava make:command PruneUsers
Generated file (app/commands/SendEmails.php):
<?php
/**
* Command: SendEmails
*
* Auto-discovered by the LavaLust CLI.
* No registration needed — just drop this file in app/commands/.
*/
class SendEmails
{
/**
* The CLI command name.
* Usage: php lava send:emails
*/
public static $command = 'send:emails';
/** Short description shown in php lava help */
public static $description = 'Description for send:emails';
/**
* Argument/flag descriptions shown in help.
*
* Example:
* public static $arguments = [
* 'name' => 'A positional argument',
* '[--flag=<v>]' => 'An optional flag',
* ];
*/
public static $arguments = [];
/**
* Command entry point.
*
* @param string|null $input First positional argument (php lavasend:emails <input>)
* @param array $flags Associative array of --flag=value pairs
*/
public function handle($input = null, array $flags = [])
{
// TODO: Add your command logic here
echo "Running SendEmails..." . PHP_EOL;
}
}
Registering the command in lava:
php lava send:emails
php lava send:emails --dry-run
Utility Commands
route:list
Parses app/config/routes.php and prints a table of all registered routes.
php lava route:list
Output:
Registered Routes
────────────────────────────────────────────────────────────────────────
Method URI Handler
────────────────────────────────────────────────────────────────────────
GET / HomeController@index
GET /users UsersController@index
POST /users UsersController@store
GET /users/{id} UsersController@show
PUT /users/{id} UsersController@update
DELETE /users/{id} UsersController@destroy
────────────────────────────────────────────────────────────────────────
Total: 6 route(s) found.
Note
route:list uses regex pattern matching against your routes.php file.
Routes defined inside closures, or routes that use complex dynamic registration,
may not be detected. Only routes following the standard
$router->method('/path', 'Controller::method') pattern are shown.
key:generate
Generates a cryptographically secure 64-character hex key and writes it to your
.env file as APP_KEY. If APP_KEY already exists in .env it is
replaced; otherwise the key is appended.
php lava key:generate
Output (when .env exists):
Generated key: 3f8a2c1d...e9b47f06
APP_KEY updated in .env
Output (when no .env file is found):
Generated key: 3f8a2c1d...e9b47f06
Note: No .env file found. Copy the key above and set APP_KEY manually.
Note
Run key:generate once during initial project setup, or whenever you need
to rotate the application key. Never share or commit your APP_KEY to version
control — it is used to secure sessions and encrypted values.
env:check
Reads your .env file and prints a sanitised summary. Sensitive values
(anything not in the safe whitelist) are masked with asterisks.
php lava env:check
Output:
Environment Summary
──────────────────────────────────────────────────
APP_NAME My Application
APP_ENV development
APP_DEBUG true
APP_URL http://localhost
DB_CONNECTION mysql
DB_HOST 127.0.0.1
DB_PORT 3306
DB_DATABASE my_database
DB_USERNAME ********
DB_PASSWORD ********
CACHE_DRIVER file
SESSION_DRIVER file
──────────────────────────────────────────────────
PHP 8.2.0 · Linux
Whitelisted keys (shown as plain text):
|
|
|
|
|
|
|
|
|
|
All other keys are masked. Comments (lines beginning with #) are skipped.
Subdirectory Support
All make:* commands support nested subdirectories using forward slashes.
The CLI creates any missing intermediate directories automatically.
Command |
Generated path |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
File Overwrite Protection
If a file already exists at the target path the CLI will not overwrite it. An error message is shown instead:
Controller "Dashboard" already exists.
Delete the existing file manually before regenerating it.
Getting Help
Running php lava with no arguments prints the full grouped command reference:
php lava
Output:
LavaLust CLI Code Generator
Usage: php lava <command> [options]
Server:
serve → Start PHP built-in development server
[port] Port number (default: 3000)
[--port=<n>] Port number via flag (e.g. --port=8080)
Cache:
cache:clear → Clear all files in runtime/cache
Makers:
make:controller → Creates a controller
make:model → Creates a model
make:middleware → Creates a middleware
make:helper → Creates a helper
make:library → Creates a library
make:view → Creates a view file
make:language → Creates a language file
make:config → Creates a config file
make:command → Creates a custom CLI command
Utilities:
route:list → Display all registered routes
key:generate → Generate a new application key
env:check → Display current environment configuration summary
Examples:
php lava serve
php lava serve 8080
php lava serve --port=8080
php lava make:controller Dashboard
php lava make:model User
php lava cache:clear
php lava route:list
php lava env:check
php lava key:generate
Tips and Best Practices
Run
php lava serveduring local development instead of configuring a full web server.Use the
--portflag (php lava serve --port=8080) when port 3000 is already in use.Use subdirectory syntax (e.g.
Admin/UserController) from the start to keep larger applications organised.After generating a model, fill in
$table,$fillable, and$guardedbefore using it with the Query Builder.After generating a middleware, register it in
app/config/middleware.phpbefore attaching it to routes.Run
php lava key:generateonce during initial project setup and whenever you rotate the application key.Use
php lava env:checkto quickly verify your environment settings on a new server without opening the.envfile directly.Use
php lava route:listto audit all registered routes before deploying — it is a quick way to spot misconfigured or forgotten routes.Generated files are a starting point — always add your own logic after scaffolding.
Use
make:configfor feature-specific settings rather than adding everything to the mainconfig.php.Use
make:commandto encapsulate recurring maintenance tasks (sending emails, pruning old records, syncing data) as named CLI commands instead of writing one-off scripts.