LilaPHP

Operations & Deploy

CLI Engine & Automation

LilaPHP provides a zero-dependency command line interface in cli.php at the project root. It handles dev server execution with hot reload, database switching, automatic code scaffolding, sitemap/robots generation, migrations, health audits, and Docker orchestration.

1. Local Development Server (`dev`)

Boot the built-in development server targeting public/ as the document root with live hot reload enabled:

php cli.php dev 8080

This launches PHP's built-in web server with root router index.php. It enables automatic live reloading whenever files in app/views/ or public/css/ are modified.

2. Database Provider Switcher (`db:switch`)

Switch between MySQL and SQLite with a single command. It updates your root .env file, flushes the OPcache environment cache, and verifies database connectivity:

# Switch to SQLite standalone mode
php cli.php db:switch sqlite

# Switch back to MySQL
php cli.php db:switch mysql

3. Scaffolding Generators (`make`)

Create REST API Resource (`make:api`)

Generates a complete REST API controller with GET (list & single), POST (validation & create), PUT (update), and DELETE endpoints:

php cli.php make:api Product

Creates app/routes/api/products.php mapped to /api/products.

Create Full CRUD Suite (`make:crud [--embed]`)

Generates Model, REST API route, Web view template, and Web route in a single command:

# Standard CRUD with full layout
php cli.php make:crud Order

# Embeddable CRUD (standalone view with layout => false for iframe embedding)
php cli.php make:crud Order --embed

Create Web Route (`make:route`)

php cli.php make:route contact

Creates app/routes/contact.php.

Create Database Model (`make:model`)

php cli.php make:model Customer

Creates app/models/Customer.php.

4. SEO Automation (`sitemap` & `robots`)

Generate Sitemap (`public/sitemap.xml`)

Scans all web routes in app/routes/, checks for $noIndex = true or $protectedRoute = true, and compiles valid XML:

php cli.php sitemap

Generate Robots (`public/robots.txt`)

Generates public/robots.txt pointing to the sitemap and disallowing protected paths:

php cli.php robots

5. System Diagnostics (`doctor` & `health`)

php cli.php doctor
php cli.php health

The doctor command verifies:

  • PHP 8.2+ binary version and required extensions (PDO, OpenSSL, mbstring, cURL, etc.).
  • Presence and permissions of root .env.
  • Validity of public directory (public/css/bluebird.css, public/manifest.json).
  • Verification that all views referenced in app/routes/*.php exist in app/views/.
  • Database connectivity (MySQL or SQLite).

6. Docker Orchestration

# Start standard dev cluster (Nginx, PHP-FPM, MySQL, Redis)
php cli.php docker dev

# Start low-RAM SQLite standalone cluster (exclusively Nginx, PHP-FPM, Redis)
php cli.php docker sqlite

# Start production cluster
php cli.php docker prod

# Inspect running container stats
php cli.php docker stats

7. Database Migrations & Optimization

# Auto-migrate database tables from app/models/
php cli.php migrate

# Fresh migration from scratch
php cli.php migrate --refresh

# Generate secure APP_KEY in root .env
php cli.php key:generate

# Pre-cache .env configuration to OPcache
php cli.php optimize