#}

CLI Commands

Complete reference for all GEMVC command-line tools

GEMVC CLI Commands

Getting Started

Access the CLI through Composer's vendor binary:

CLI Access
# Show all available commands
php vendor/bin/gemvc

# Get help for a specific command
php vendor/bin/gemvc help create:crud

Project Commands

Project Initialization
# Initialize a new GEMVC project
php vendor/bin/gemvc init

# Initialize with specific server configuration
php vendor/bin/gemvc init --swoole      # OpenSwoole server
php vendor/bin/gemvc init --apache      # Apache configuration
php vendor/bin/gemvc init --nginx       # Nginx configuration

# Non-interactive initialization
php vendor/bin/gemvc init --server=swoole --non-interactive
Tip: The init command creates the entire project structure including directories, configuration files, and sample code.

Code Generation Commands

CRUD Generation

CRUD Generation
# Create complete CRUD (service + controller + model + table)
php vendor/bin/gemvc create:crud User

# This generates:
# - App/Api/UserService.php
# - App/Controller/UserController.php
# - App/Model/User.php
# - App/Table/UserTable.php

Individual Components

Component Generation
# Create API service class
php vendor/bin/gemvc create:service UserService

# Create service with additional components
php vendor/bin/gemvc create:service UserService -c    # Include controller
php vendor/bin/gemvc create:service UserService -m    # Include model
php vendor/bin/gemvc create:service UserService -t    # Include table
php vendor/bin/gemvc create:service UserService -cmt  # Include all

# Create other components individually
php vendor/bin/gemvc create:controller UserController
php vendor/bin/gemvc create:model User
php vendor/bin/gemvc create:table users

Database Commands

Database Commands
# Initialize database connection and verify
php vendor/bin/gemvc db:init

# Run database migrations
php vendor/bin/gemvc db:migrate UserTable
php vendor/bin/gemvc db:migrate UserTable --force           # Force migration (removes extra columns)
php vendor/bin/gemvc db:migrate UserTable --sync-schema     # Sync schema constraints
php vendor/bin/gemvc db:migrate UserTable --enforce-not-null  # Enforce NOT NULL
php vendor/bin/gemvc db:migrate UserTable --default="Active"  # Set default for new columns

# Database information
php vendor/bin/gemvc db:list              # List all tables
php vendor/bin/gemvc db:describe users    # Describe table structure

# Database modifications
php vendor/bin/gemvc db:drop users        # Drop a table (with confirmation)
php vendor/bin/gemvc db:unique users email  # Add unique constraint to column
info: Always backup your database before running migrations with --force flag!

Command Reference Table

Command Description Options
init Initialize new project --swoole, --apache, --nginx, --server=name, -n
create:crud Generate complete CRUD -
create:service Create API service -c, -m, -t, -cmt
create:controller Create controller -m, -t, -mt
create:model Create model class -t
create:table Create table class -
db:init Initialize database -
db:migrate Run migrations --force, --sync-schema, --enforce-not-null, --default=val
db:list List all tables -
db:describe Describe table -
db:drop Drop table -
db:unique Add unique constraint -

Complete Workflow Example

Complete Workflow
# 1. Initialize project
php vendor/bin/gemvc init --swoole

# 2. Initialize database
php vendor/bin/gemvc db:init

# 3. Create CRUD for Product
php vendor/bin/gemvc create:crud Product

# 4. Migrate Product table
php vendor/bin/gemvc db:migrate ProductTable

# 5. List all tables
php vendor/bin/gemvc db:list

# 6. Describe Product table
php vendor/bin/gemvc db:describe products

Next Steps