Skip to content

CLI Commands

lpachecob edited this page Mar 26, 2026 · 5 revisions

🚀 CLI Commands: The BOUNDLY Engine

BOUNDLY is driven by Artisan CLI commands that cover the full lifecycle of development and production.


🛰️ core:watch

Starts the development server and automatically synchronizes the database on entity changes. This is your primary development tool.

Parameters:

  • {--lang=en} - Set the CLI output language (en or es).
  • {--port=8000} - Set the port for the development server.

What it does:

  1. Initial Sync — Scans Domain/ and Application/ immediately on startup.
  2. Auto DB Sync — Monitors for file changes. If you modify an #[Entity], core:migrate is called automatically.
  3. Rest Server — Launches the API at http://127.0.0.1:8000.
php artisan core:watch --lang=es

🪄 core:migrate

The safe schema evolution engine. Scans your entities and translates attributes into SQL DDL commands. Zero migration files needed.

Parameters:

  • {--lang=en} — Set the CLI output language.
  • {--dry-run}Preview what would change without touching the database.

What it does:

  1. Fingerprinting — Hashes each entity's schema. If unchanged, it is skipped entirely (idempotent).
  2. History Tracking — Records every applied change in the boundly_migrations table.
  3. Non-Destructive — Never drops columns or tables automatically. Human approval required for destructive ops.
  4. Smart Evolution — Adds new columns, audit fields, soft-delete columns, and FK columns as needed.
  5. Column Type Mapping — Automatically maps bigint to Laravel's bigInteger for proper Blueprint support.
  6. Audit Column Handling — When using #[Column] for created_by or updated_by, the framework skips auto-adding them via #[Auditable] to prevent duplicates.

Column Type Mapping

The framework automatically maps column type aliases to Laravel Blueprint methods:

Attribute Type Laravel Method
bigint bigInteger()
bigintunsigned bigInteger()
# Preview changes without applying them
php artisan core:migrate --dry-run

# Apply changes
php artisan core:migrate

core:cache

Caches the entire entity/action metadata registry into a static PHP file (bootstrap/cache/boundly.php). Required before deploying to production.

Parameters:

  • {--clear} — Deletes the cache file (run after Domain/Application changes in development).

How it works:

  • In production (when the cache file exists), the framework reads from a fast require call — no filesystem scanning, no reflection.
  • In local/development (cache disabled via BOUNDLY_DISABLE_CACHE=true), the engine scans and reflects on every request.
# Build cache (before deploy)
php artisan core:cache

# Clear cache (during development)
php artisan core:cache --clear

📄 core:docs

Auto-generates a full OpenAPI 3.0 (Swagger) specification from your Entity metadata. Zero documentation effort.

Parameters:

  • {--format=json} — Output format (json or yaml).
  • {--out=} — Custom output file path (default: storage/app/openapi.json).

What gets generated:

  • All CRUD paths (GET, POST, PUT, PATCH, DELETE) per resource.
  • Full JSON Schema per entity (types, max lengths, nullable, required).
  • Pagination metadata structure.
php artisan core:docs
# → Open storage/app/openapi.json in https://editor.swagger.io

🏗️ core:make:entity

Auto-generates a Pure Domain Entity pre-configured for BOUNDLY. This command enforces the correct DDD structure and eliminates boilerplate.

Parameters:

  • {name} — The singular name of the Entity (e.g., Product, Invoice).
  • {--a|auditable} — Automatically import and apply the #[Auditable] attribute.
  • {--s|soft-delete} — Automatically import and apply the #[SoftDelete] attribute.

What gets generated:

  • Automatically resolves the pluralized Domain directory (e.g., Domain/Products/Entities/).
  • Outputs a ready-to-use PHP Entity with #[Entity], #[Id], #[Column], and the AggregateRoot trait.
# Generate a simple entity
php artisan core:make:entity Invoice

# Generate an entity with audit and soft-delete features
php artisan core:make:entity Order --auditable --soft-delete

🧪 core:make:test

Auto-generates smart API test stubs for your Domain Entities.

Parameters:

  • {resource?} — (Optional) The specific entity resource or table to generate tests for. If omitted, it generates tests for all entities.

What gets generated:

  • Parses the entity's #[Column] types and limits to generate a valid mock payload (e.g., inserts a valid email if the column is named 'email', injects an integer if it's an integer column).
  • Creates a PHPUnit class inside Domain/{YourDomain}/Tests/{Entity}ApiTest.php to enforce DDD organization.
# Generate tests for all entities
php artisan core:make:test

# Generate tests only for users
php artisan core:make:test users

🌍 Language Support

Flag Language
--lang=en English (Default)
--lang=es Spanish

You can also set the permanent language in config/boundly.php via BOUNDLY_LOCALE.


🔑 Recommended Production Workflow

# 1. Preview schema changes
php artisan core:migrate --dry-run

# 2. Apply schema changes
php artisan core:migrate

# 3. Cache metadata for production performance
php artisan core:cache

# 4. Generate up-to-date API documentation
php artisan core:docs

Next Step: Configuration ⚙️

Clone this wiki locally