PHPackages                             spatial/cli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. spatial/cli

ActiveLibrary[CLI &amp; Console](/categories/cli)

spatial/cli
===========

CLI tools for Spatial Framework - code generators, migrations, and development utilities

1.1.0(4mo ago)091MITPHPPHP ^8.2

Since Dec 14Pushed 4mo agoCompare

[ Source](https://github.com/aiira-co/spatial-cli)[ Packagist](https://packagist.org/packages/spatial/cli)[ RSS](/packages/spatial-cli/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (4)Used By (1)

Spatial CLI
===========

[](#spatial-cli)

Development tools for Spatial Framework - code generators, migrations, and development utilities.

[![PHP Version](https://camo.githubusercontent.com/187240af044d09d5b14a1d9d9ebdf3f7a993e4c7bc09bdb46b4ba661a891bf5b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d626c7565)](https://php.net)[![License](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)](LICENSE)

Installation
------------

[](#installation)

```
composer require spatial/cli --dev
```

Commands (21)
-------------

[](#commands-21)

### Generators (13)

[](#generators-13)

CommandDescription`make:controller`Controller with Area + CQRS`make:command`CQRS command + handler`make:query`CQRS query + handler`make:module`API module structure`make:dto`DTO with validation`make:entity`Doctrine entity`make:service`Infrastructure service`make:middleware`PSR-15 middleware`make:trait`Domain DB trait`make:event`Domain event`make:listener`Event listener`make:seeder`Database seeder`make:job`Background job### Database (4)

[](#database-4)

CommandDescription`migrate:create`Create migration`migrate:run`Run migrations`migrate:status`Migration status`db:seed`Run seeders### Quality (2)

[](#quality-2)

CommandDescription`lint`PSR-12 code style`analyze`PHPStan analysis### Build (2)

[](#build-2)

CommandDescription`deploy:build`Package for production`openapi:generate`Generate OpenAPI specUsage
-----

[](#usage)

```
# Generate a complete feature with full observability
php vendor/bin/spatial make:module OrdersApi
php vendor/bin/spatial make:entity Order --schema=Orders
php vendor/bin/spatial make:command CreateOrder --module=Orders --entity=Order --logging --tracing
php vendor/bin/spatial make:query GetOrders --module=Orders --entity=Order --logging --tracing --releaseEntity
php vendor/bin/spatial make:listener SendOrderEmail --event=OrderCreatedEvent --logging
php vendor/bin/spatial make:controller Order --module=OrdersApi --logging --auth

# Generate clean code without OTEL (minimal dependencies)
php vendor/bin/spatial make:query GetUsers --module=Identity --entity=User
php vendor/bin/spatial make:command UpdateProfile --module=Identity --entity=User
php vendor/bin/spatial make:controller Product --module=CatalogApi

# Generate middleware with observability
php vendor/bin/spatial make:middleware RateLimit --logging --tracing

# Generate background job with custom retry count
php vendor/bin/spatial make:job ProcessPayments --queue=payments --logging --tracing --retry=5

# Database operations
php vendor/bin/spatial migrate:create AddOrdersTable
php vendor/bin/spatial migrate:run
php vendor/bin/spatial db:seed

# Code quality
php vendor/bin/spatial lint --fix
php vendor/bin/spatial analyze --level=5

# Build for production
php vendor/bin/spatial deploy:build --output=dist
```

Dry-Run Mode
------------

[](#dry-run-mode)

Preview generated code without creating files:

```
# Preview what will be generated
php vendor/bin/spatial make:query GetUsers --module=Identity --entity=User --dry-run

# Preview with all flags
php vendor/bin/spatial make:controller Order --module=OrdersApi --logging --tracing --auth --dry-run

# Aliases: --dry-run, --preview
```

Output shows:

- File paths that would be created
- Line counts and file sizes
- First 20 lines of each file as preview
- Full content can be reviewed before committing

Smart Error Messages
--------------------

[](#smart-error-messages)

The CLI provides contextual help when errors occur:

**Typo Detection:**

```
php spatial make:query GetUsers --module=Identty --entity=User

# Output:
# ❌ Module 'Identty' not found.
#
# 💡 Suggestions:
#    • Did you mean: IdentityApi?
#    • Create the module first: php spatial make:module Identty
```

**Missing Parameters:**

```
php spatial make:query GetUsers --entity=User

# Output:
# ❌ Both --module and --entity parameters are required.
#
# 💡 Suggestions:
#    • Available modules: IdentityApi, OrdersApi, PaymentsApi
#
# 📖 Correct usage:
#    php spatial make:query  --module= --entity=
```

Optional Flags
--------------

[](#optional-flags)

All generators support optional flags for fine-grained control over generated code:

### Common Flags

[](#common-flags)

- `--logging` - Include PSR-3 LoggerInterface dependency injection and logging calls
- `--tracing` - Include OpenTelemetry TracerInterface dependency injection and span tracking

### Generator-Specific Flags

[](#generator-specific-flags)

- `make:query`, `make:command`
    - `--releaseEntity` - Add entity manager cleanup in finally block
- `make:controller`
    - `--auth` - Add #\[Authorize\] attributes to POST/PUT/DELETE endpoints
- `make:job`
    - `--retry=` - Set custom retry attempts (default: 3)
    - `--queue=` - Set queue name (default: default)
- `make:middleware`
    - `--folder=` - Set folder name (default: Middlewares)

Configuration
-------------

[](#configuration)

Create a `.spatial.yml` file in your project root to define default generator settings and avoid repetitive flag usage.

### Example Configuration

[](#example-configuration)

```
generators:
  # Global defaults for all generators
  defaults:
    logging: true
    tracing: false
    releaseEntity: true

  # Override defaults for specific generators
  overrides:
    make:query:
      tracing: true # Always trace queries
    make:controller:
      auth: true # Controllers protected by default
    make:job:
      retry: 5 # Custom retry count
```

### Priority System

[](#priority-system)

Configuration values are resolved in this order (highest to lowest):

1. **CLI Flags** - Explicit command-line arguments
2. **Generator Overrides** - Command-specific config (`make:query`, `make:command`, etc.)
3. **Global Defaults** - Project-wide defaults
4. **Hardcoded Defaults** - Built-in framework defaults

### Usage Examples

[](#usage-examples)

**With config file:**

```
generators:
  defaults:
    logging: true
```

This command:

```
php spatial make:query GetUsers --module=Identity --entity=User
```

Automatically includes logging (from config), equivalent to:

```
php spatial make:query GetUsers --module=Identity --entity=User --logging
```

**Override config with CLI:**

```
# Config has logging: true, but CLI forces it off
php spatial make:query GetTest --module=Test --entity=Test
# (Remove logging from generated file manually or regenerate without config)
```

**See .spatial.yml.example for a complete configuration template.**

Package Separation
------------------

[](#package-separation)

This package contains **development tools only**.

PackageCommandsInstall`spatial/core`5 runtime (route:*, cache:*, queue:work)`require``spatial/cli`21 development`require-dev`License
-------

[](#license)

MIT - Created by [Kofi Owusu-Afriyie](https://aiira.co)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance77

Regular maintenance activity

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Total

3

Last Release

128d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/89a7841218dbe957691b40303edd1b54b253070d3e8750b39ed705b2ddb6ed8d?d=identicon)[spatial](/maintainers/spatial)

---

Top Contributors

[![aiira-co](https://avatars.githubusercontent.com/u/28719431?v=4)](https://github.com/aiira-co "aiira-co (5 commits)")

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spatial-cli/health.svg)

```
[![Health](https://phpackages.com/badges/spatial-cli/health.svg)](https://phpackages.com/packages/spatial-cli)
```

###  Alternatives

[drush/drush

Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

2.4k57.4M685](/packages/drush-drush)[crunzphp/crunz

Schedule your tasks right from the code.

2292.0M6](/packages/crunzphp-crunz)[crazywhalecc/static-php-cli

Build single static PHP binary, with PHP project together, with popular extensions included.

1.8k13.9k](/packages/crazywhalecc-static-php-cli)[phpcr/phpcr-shell

Shell for PHPCR

721.3M8](/packages/phpcr-phpcr-shell)[madewithlove/license-checker

CLI tool to verify allowed licenses for composer dependencies

54449.8k21](/packages/madewithlove-license-checker)[chromatic/usher

A collection of Robo commands for use on Chromatic projects.

13534.3k1](/packages/chromatic-usher)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
