Available Utilities
SigmaPHP provides a built-in command-line interface (CLI) that simplifies common development and application management tasks. It offers a collection of utilities for generating application components, managing database migrations and seeders, maintaining cached views, inspecting routes, running tests, and starting the application.
The CLI follows a consistent command structure, with support for global options that allow you to customize configuration paths, control output verbosity, display help information, and inspect the application version.
Usage
All CLI utilities follow the same general syntax:
./bin/sigma-cli [COMMAND] [OPTIONS] [--] [ARGUMENTS]
Replace [COMMAND] with the desired utility, and provide any
supported options or arguments required by that command.
All commands can be executed using the sigma-cli executable located inside
the bin directory.
./bin/sigma-cli --help
Windows Users
If you are using Windows, you can execute the CLI commands using the
sigma-cli.bat file instead.
.\bin\sigma-cli.bat --help
Available Commands
SigmaPHP CLI organizes its built-in commands into three categories, providing utilities for framework management, application development, and database operations:
Application Components
These commands help you generate the core components of your application:
create:command {command name}
Generate a new console command class.
./bin/sigma-cli create:command ValidateOrders
create:controller {controller name}
Generate a new controller class.
./bin/sigma-cli create:controller UserController
create:middleware {middleware name}
Generate a new middleware class.
./bin/sigma-cli create:middleware AuthMiddleware
create:migration {migration name}
Generate a new migration file used for managing database schema changes.
./bin/sigma-cli create:migration create_users_table
create:model {model name}
Create a new model class. Use the -m, --with-migration option
to generate a corresponding migration file for the model.
./bin/sigma-cli create:model User --with-migration
create:seeder {seeder name}
Generate a database seeder class used to populate tables with sample or initial data.
./bin/sigma-cli create:seeder UserSeeder
create:provider {service provider name}
Generate a new service provider used to register dependencies and services inside the container.
./bin/sigma-cli create:provider AppServiceProvider
create:view {view name}
Generate a new view template file.
./bin/sigma-cli create:view users/index
Database Management
Use the following commands to manage database migrations, seeders, and table data:
migrate
Run the application's pending database migrations. Use the
-f, --file <string> option to run a specific migration file.
./bin/sigma-cli migrate
./bin/sigma-cli migrate --file CreateUsersTable
seed {seeder name}
Run one or more database seeders. Use the
-f, --file <string> option to run a specific seeder file.
./bin/sigma-cli seed UserSeeder
./bin/sigma-cli seed --file UserSeeder
rollback
Rollback database migrations. By default, the command rolls back all migrations
to the beginning. To rollback to a specific date, use the -d or
--date option.
The date must follow the YYYY-M-D format, for example,
2023-1-20.
# Rollback all migrations
./bin/sigma-cli rollback
# Rollback to a specific date
./bin/sigma-cli rollback --date=2023-1-20
# Using the shorthand option
./bin/sigma-cli rollback -d=2023-1-20
truncate
Delete all data from every table in the database without removing the table structures.
./bin/sigma-cli truncate
drop
Drop all tables in the configured database.
./bin/sigma-cli drop
fresh
Drop all tables in the database, then run all migrations and seed the database again.
./bin/sigma-cli fresh
Application Utilities
Additional commands are available for common application maintenance and development tasks:
clear:cache
Clear the application's compiled view cache.
./bin/sigma-cli clear:cache
create:secret
Generate a new application secret key and automatically save it into the
.env file.
./bin/sigma-cli create:secret
create:uploads
Creates the uploads directory used to store uploaded files and generates a
symbolic link to it inside the public directory, making uploaded files accessible through the web.
./bin/sigma-cli create:uploads
list:routes
Display the routes registered in the application.
./bin/sigma-cli list:routes
run {port}
Run the application using PHP's built-in development server. By default,
the server listens on port 8888. You can specify a custom port when needed.
./bin/sigma-cli run
To use a custom port:
./bin/sigma-cli run 8080
test
Execute the application's unit tests.
./bin/sigma-cli test
Global Options
SigmaPHP CLI provides a set of global options that can be used to control command execution and customize the CLI behavior. These options are available across the application's commands.
-
-h, --help— Display the help menu. -
-q, --quiet— Suppress normal output and display errors only. -
-s, --silent— Suppress all output, including errors. -
-v, --verbose— Display detailed debug information. -
-V, --version— Display the application's version.
You might notice a global option called --config listed in the help menu, which allows specifying a configuration file path.
This option is used exclusively by database commands for internal purposes and can be safely ignored during normal application development.
Getting Command Help
Every command provides its own help information, allowing you to inspect its available options, arguments, and usage details.
To display the help information for a specific command, append
--help to its name:
./bin/sigma-cli [COMMAND] --help
For example, to display the available options and usage information for the migration command:
./bin/sigma-cli migrate --help
This makes it easy to explore the available utilities and understand how to use each command without having to consult its implementation.