VOOZH about

URL: https://deepwiki.com/mathsgod/light/9.1-cli-overview-(binlight)

⇱ CLI Overview (bin/light) | mathsgod/light | DeepWiki


Loading...
Last indexed: 31 January 2026 (cf9511)
Menu

CLI Overview

The Light framework provides a command-line interface through the bin/light executable for database installation and code generation. The CLI is built on Symfony Console, providing a robust command framework with built-in help, argument parsing, and extensibility.

For detailed information about specific commands, see:

Symfony Console Foundation

The CLI tool at bin/light1-24 is a PHP script that creates a Symfony\Component\Console\Application instance and registers command classes. This architecture provides:

  • Standardized command structure with configure() and execute() methods
  • Automatic help text generation via --help flag
  • Input argument and option validation
  • Command discovery and listing via bin/light list
  • Interactive input handling

CLI Application Initialization:


Sources: bin/light1-24

Command Structure

All commands follow Symfony Console conventions and are invoked using:


Each command is implemented as a class extending Symfony\Component\Console\Command\Command with:

  • configure() method defining command name, description, arguments, and options
  • execute() method containing command logic

The framework automatically handles:

  • Command name routing based on registration at bin/light17-21
  • Help text display via --help flag
  • Argument validation and type coercion
  • Error handling and exit codes

Command Execution Flow:


Sources: bin/light15-23

Registered Commands

The CLI registers five commands through the addCommand() method at bin/light17-21 Each command is instantiated and added to the application container:

Command Registration Mapping:


Sources: bin/light6-21

Command Summary Table

Command ClassCLI Command NamePurposePrimary Output
Light\Command\DbInstallCommanddb:installInitialize database schema and seed admin dataDatabase tables from db.json
Light\Command\MakeControllerCommandmake:controllerGenerate GraphQL controller with CRUD methodssrc/Controller/{Name}Controller.php
Light\Command\MakeModelCommandmake:modelGenerate model class from database tablesrc/Model/{Name}.php
Light\Command\MakeInputCommandmake:inputGenerate GraphQL input types for mutationssrc/Input/{Name}.php
Light\Command\MakeTsCommandmake:tsGenerate TypeScript type definitionsTypeScript output to stdout

Each command class is documented in detail in subsequent sections:

Sources: bin/light6-21

Database Schema Source

The CLI commands that generate code (make:model, make:controller, make:input, make:ts) and the database installation command (db:install) all depend on the database schema definition stored in db.json. This file serves as the single source of truth for:

  • Table structure and column definitions
  • Primary keys, foreign keys, and indexes
  • Column types, lengths, nullability, and defaults
  • Database constraints and relationships

Schema-Driven Architecture:


Sources: db.json1-676 bin/light6-21

Example Schema Entries

The db.json file defines tables as JSON objects with columns, keys, and constraints:

User Table Definition:

  • Primary key: user_id (auto-increment) at db.json6-11
  • Unique constraint on username at db.json131-138
  • Columns: username, password, email, phone, addresses, status, language, settings, OAuth fields
  • Timestamps: created_time at db.json116-118

Role Table Definition:

UserRole Junction Table:

EventLog Audit Table:

Sources: db.json1-418

Usage Examples

Install database and create admin user:


Generate model from Product table:


Generate controller for Product:


Generate input types for Product:


Generate TypeScript definitions:


Preview generated code without writing files:


Sources: bin/light23-423

Standard Imports and Annotations

All generated code includes standard imports for GraphQL integration:

Model Imports bin/light226-230:

  • TheCodingMachine\GraphQLite\Annotations\Field
  • TheCodingMachine\GraphQLite\Annotations\MagicField
  • TheCodingMachine\GraphQLite\Annotations\Type

Controller Imports bin/light91-97:

  • TheCodingMachine\GraphQLite\Annotations\InjectUser
  • TheCodingMachine\GraphQLite\Annotations\Query
  • TheCodingMachine\GraphQLite\Annotations\Mutation
  • TheCodingMachine\GraphQLite\Annotations\Right
  • TheCodingMachine\GraphQLite\Annotations\Logged
  • TheCodingMachine\GraphQLite\Annotations\UseInputType

Input Imports bin/light306-307:

  • TheCodingMachine\GraphQLite\Annotations\Field
  • TheCodingMachine\GraphQLite\Annotations\Input

Sources: bin/light91-97 bin/light226-230 bin/light306-307

Initial Data Seeding

The db:install command seeds the database with initial data after schema creation:

Seeded Data:


The admin user password is hashed using password_hash() with PASSWORD_DEFAULT algorithm bin/light41

Sources: bin/light23-67 db.json1-672