assegaiphp / console
The Assegai CLI is a command-line interface tool that helps you to initialize, develop and maintain your Assegai applications.
Requires
- php: >=8.4
- ext-pdo: *
- assegaiphp/common: ^0.10.1 || ~0.11.0
- atatusoft-ltd/plural: ^1.2
- composer/semver: ^3.4
- laravel/prompts: ^0.3
- symfony/console: ^8.0
Requires (Dev)
- pestphp/pest: ^4.1
- phpstan/phpstan: ^1.11
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 0.11.1
- 0.11.0
- 0.10.6
- 0.10.5
- 0.10.4
- 0.10.3
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.5
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.4
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.4.7
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.17
- 0.3.16
- 0.3.15
- 0.3.14
- 0.3.13
- 0.3.12
- 0.3.11
- 0.3.10
- 0.3.9
- 0.3.8
- 0.3.7
- 0.3.6
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- dev-develop
- dev-release/0.11.1
- dev-release/0.11.0
- dev-release/0.10.6
- dev-release/0.10.5
- dev-release/0.10.4
This package is auto-updated.
Last update: 2026-11-30 07:20:27 UTC
README
Assegai Console
Requirements
- PHP 8.4 (minimum)
- Composer 2.x.x
Description
The Assegai Console is the framework CLI for:
- creating new projects
- serving apps locally
- generating framework features
- exporting API contracts and clients
- working with queues, migrations, databases, and Web Components
- upgrading existing workspaces across supported framework release lines
It also supports custom schematics so teams can teach assegai generate about their own company-specific features.
Contribution workflow
For commit and pull request conventions in this repo, see:
Installation
Install the Assegai Console globally using Composer:
$ composer global require assegaiphp/console
Then make sure Composer's global bin directory is on your PATH:
$ composer global config bin-dir --absolute
If the printed directory is not already on your PATH, add it in your shell profile. For example:
$ export PATH="$PATH:$(composer global config bin-dir --absolute)"
Refer to the official Composer documentation if your global Composer home is configured differently.
Keeping the CLI current
Update an existing global installation through the CLI itself:
$ assegai global update
# shorthand
$ assegai -g update
Normal commands perform a cached, short-timeout check for stable Console releases. When a newer version exists, the notice is written to stderr so command stdout remains safe for scripts and structured output. A successful check is reused for 24 hours, a failed check is retried after one hour, and an unavailable version service never prevents the requested command from running. Set ASSEGAI_NO_UPDATE_CHECK=1 when automatic checks must be disabled in a controlled environment.
The self-updater first ships with Console 0.10.1. It cannot be retrofitted into an older binary that is already installed. A release rollout that promises a fully self-service migration from an earlier Console must distribute an updater-enabled bridge or managed installer before asking those users to run this command.
Usage
Get Started
To create a new Assegai project, run the following command:
$ assegai new my-app
This command will create a new Assegai project in the my-app directory.
The scaffold flow can also:
- initialize git
- configure a database
- write sensitive config to
config/secure.php - set up a starter users resource when ORM is enabled
Cloned projects and application keys
Keep .env.example in Git with placeholder values; each environment owns its ignored .env file. After cloning a project, run:
composer install assegai key:generate
key:generate creates a missing .env from .env.example and initializes APP_SECRET_KEY with 32 cryptographically random bytes encoded as 64 hexadecimal characters. It also works before installing project dependencies. If neither file exists, create .env first. Other settings and the example file are preserved, and the key is never printed.
To rotate an existing key, run assegai key:generate and confirm, or explicitly use assegai key:generate --force in automation. --directory (-d) selects another workspace. Existing non-placeholder keys are never replaced without approval. Rotation may invalidate tokens or encrypted data that use the old key; retain the old key where needed and restart long-running application processes. All instances of the same environment must share the same key. Do not regenerate it on every install, update, or deployment.
assegai new generates the initial key automatically. The key command updates the local .env file; deployments that inject APP_SECRET_KEY through the process environment or a secret manager must update that value there.
Development
After creating a new project, you can start the development server to preview your application in the browser.
$ cd my-app
To start the development server, navigate to the project directory and run the following command:
$ assegai serve
OpenSwoole runtime
If you want to try the long-lived runtime path instead of the default PHP development server, install the OpenSwoole extension first and then run:
$ assegai serve --runtime=openswoole
You can also persist that choice in assegai.json:
{
"development": {
"server": {
"runtime": "openswoole",
"host": "127.0.0.1",
"port": 9510,
"openswoole": {
"workerNum": 1,
"taskWorkerNum": 0,
"maxRequest": 0,
"enableCoroutine": true,
"hookFlags": "all"
}
}
}
}
If the extension is not installed, the CLI now stops early with a direct setup message instead of falling into a runtime bootstrap failure.
The current OpenSwoole path is still experimental. It is intended for careful testing and advanced runtime work, not as a blanket replacement for the default php runtime in every project.
Upgrading existing projects
Console maintains explicit compatible package recommendations. The supported Core baseline is ^0.11.0; ORM, Events and the other compatible companion packages retain their published 0.10 lines. Package recommendations are independent of the running CLI's version metadata. Composer constraints such as ^0.10.0 exclude Core 0.11, so update the global CLI before migrating an existing project:
$ assegai global update
# or: assegai -g update
$ assegai --version
$ assegai update --to=0.11 --dry-run
$ assegai update --to=0.11
The dry run lists every direct requirement change and the Composer update set without changing files. A cross-release update then requires confirmation; non-interactive environments must pass --yes explicitly.
If the project itself requires an older assegaiphp/console, run the current globally installed CLI so Core and the local Console requirement can move to 0.11 in one Composer transaction. Installed companion packages use their own recommended constraints; compatible newer constraints and independent queue-driver constraints are preserved. The update does not require ORM or Events 0.11 releases.
The command hydrates assegai.json, updates composer.json, and runs Composer with all dependent packages. It does not rewrite application PHP source or create config/auth.php. Review the update advisor for the application-owned configuration and verification steps. If Composer fails, the CLI restores assegai.json, composer.json, and composer.lock; run composer install if Composer changed vendor/ before failing.
Generating code
Use assegai generate (or assegai g) to scaffold framework artifacts:
$ assegai g resource users $ assegai g component app --flat $ assegai g page dashboard --path src/Admin
Useful options include:
--flatto generate directly into the target path instead of creating a name-based subdirectory--pathto place generated files at a source-relative path--language php|ppphpto select the authored source language for that invocation
Generators read sourceRoot, sourceNamespace, and language from assegai.json.
Native PHP remains the default. Keep sourceNamespace explicit when a compiler
projects Composer autoload mappings into an emitted directory. For example:
{
"sourceRoot": "app",
"sourceNamespace": "Acme\\Catalog",
"language": "ppphp"
}
Built-in ++PHP sources use strict types and typed declarations. Modules may be
ordinary PHP or ++PHP; documented errors become native throws clauses in
++PHP sources. Rendering requires PHP's tokenizer extension.
Generators update the closest owning module. Custom
stubs retain their contents and can use __LANGUAGE__ and
__SOURCE_EXTENSION__ (.php or .ppphp) explicitly. Web Component assets
remain owned by the existing Web Component build/watch commands.
Package, schematic, API and queue discovery use Composer's config.vendor-dir
when configured, including an explicit external dependency directory.
Selecting ++PHP for generation does not install a compiler or build the project.
Run the configured compiler workflow before using the generated sources.
To create a mixed ++PHP project with a selected local compiler:
assegai new catalog --language=ppphp --compiler=/absolute/path/to/ppphp
The compiler must support managed Assegai initialization, guarded first-build
configuration, build and doctor. The CLI checks these capabilities before
creating the workspace. Native PHP remains the default for assegai new.
The root module and controller use ++PHP; the starter service, startup and
configuration retain native PHP bodies. The selected compiler owns the build
configuration. Creation succeeds after dependency installation, the complete
first build, Composer lock/autoload refresh, and verification of the final build.
Failures preserve the new workspace for inspection and do not report it ready.
API exports from a selected compiled application
Use an explicitly selected compiler to read the verified API artifact attached to its selected application:
assegai api:export openapi --compiler=/absolute/path/to/ppphp assegai api:export postman --compiler=/absolute/path/to/ppphp assegai api:client typescript --compiler=/absolute/path/to/ppphp
The OpenAPI command writes the selected bytes to standard output by default.
An explicit --output writes an export copy. Compiled exports preserve the
standalone generated/openapi.json file, and reject invalid selection,
readiness or artifact identities. These explicit compiled commands skip
authored package-extension discovery and delegate selection ownership to the
compiler.
Compiled development
Select the local compiler and all runtime locations explicitly:
assegai serve --dev --compiler=/absolute/path/to/ppphp \ --state=/absolute/path/to/state \ --environment=/absolute/path/to/private-secrets/development.env \ --composer=/absolute/path/to/composer.phar \ --generation-parent=/absolute/path/to/private-generations
All paths must already exist and be canonical absolute paths without links.
State, the environment file's directory, worker generations and authored code
must be disjoint, including any external Composer vendor directory. The
environment file and its directory, and the generation directory, must be
private. Console checks these locations without reading environment contents or
changing permissions. Composer must identify its readable PHP entrypoint.
--build-timeout=240 optionally sets a candidate limit from 1 to 600 seconds;
omitting it retains the engine's default.
Console forwards the selected PHP, runtime, host, port and browser intent to the
engine's foreground session. --open and development.server.openBrowser retain
that intent. The engine owns building, runtime validation, worker generations,
watching and browser launch. The compiler path requires --dev and HTTP;
compiler-only options cannot be used with native serving. Project autoload,
startup, API exports and native watchers are not run before the handoff, so a
first build or broken authored autoload does not prevent engine selection.
The internal dev:plan protocol remains version 1. It describes explicit
startup paths, native launcher actions and optional component watching.
Component success receipts identify output bytes. Complete frozen component
input capture remains unavailable; these receipts do not establish its source
and configuration read set. Full compiled watch/reload qualification remains
separate from startup and selected API qualification.
The internal test:plan metadata query describes the project Composer test
command for an independently prepared disposable application. It takes explicit
--runtime-root, --php, --composer, --console-entrypoint and --format=json
options. Its version 2 response contains command (argv, workingDirectory),
runner and inputHashes, alongside formatVersion, kind and framework.
runner contains tool (pest or phpunit), its absolute entrypoint, selected
XML configuration and native protectedPaths. Hashes are lowercase SHA-256 hex strings.
Planning runs before application/Console autoload and update checking, and never
executes Composer, a test bootstrap or the application.
The native descriptor supports a literal configured bin-dir/pest or
bin-dir/phpunit Composer test script, optionally prefixed by @php.
Custom script chains, runner arguments and shell syntax fail explicitly.
Configuration selection follows PHPUnit's default order: phpunit.xml,
phpunit.dist.xml, then phpunit.xml.dist. Native source ownership includes
the configured sourceRoot, even when absent. The query rechecks file hashes
and configuration selection, including absent project/configuration files.
Version 2 removes Console's XML parsing, installed runner-version validation
and mutable-cache declarations. The shared engine must apply its common
PHPUnit/Pest policy to the pinned runner/configuration before executing tests.
A successful descriptor query alone does not authorize execution or cache
exclusions. The engine must authenticate selection against its application
receipt and guard absent higher-priority files around the query and at launch.
Project Composer/XML/bootstrap bytes are preserved. Normal assegai test /
assegai t continue their existing Composer behavior.
Compiled tests
Select the compiler and test inputs explicitly:
assegai test --compiler=/absolute/path/to/ppphp \
--environment=/absolute/path/to/private-test-secrets/testing.env \
--composer=/absolute/path/to/composer.phar
assegai t supports the same options. --root selects the authored project
instead of the current directory; --config forwards a saved compiler
configuration path. Optional --build-timeout and --test-timeout accept whole
seconds from 1 through 600. Omission retains the engine defaults of 240 and 30.
These options require --compiler. No coverage, parallel or report arguments
are forwarded.
The environment file must be readable, private, independent and within one MiB, in a private directory outside authored code and installed dependencies. Composer must identify its existing readable PHP entrypoint. Paths must be canonical and contain no links. Console checks metadata without reading environment contents or changing permissions. The engine uses the saved framework profile and verifies that the selected PHP matches the CLI launch.
The engine builds and verifies one private disposable application, runs its
native Composer test recipe once, and disposes its own state and generations.
It preserves native output and exit status after integrity and cleanup checks.
Console delegates foreground ownership and skips authored package discovery;
it does not bootstrap the project or run a second test command. Plain
assegai test / assegai t retain their native Composer behavior.
The shared test owner must authenticate the disposable copy, pin PHP through Composer and its children, provide separate startup/environment/state and a private Composer home, and verify code/private-input integrity after execution. The plan provides metadata; it does not implement that orchestration or promise process containment. Deployment remains a separate application workflow.
Database-aware commands also support MySQL, MariaDB, PostgreSQL, SQLite, and MSSQL where applicable.
Web Component groups
Configure independent bundles with explicit source files or directories:
{
"webComponents": {
"groups": {
"site": {
"sources": ["src/WebComponents/Site"],
"output": "public/js/site.min.js"
},
"sandbox": {
"sources": ["src/WebComponents/PlaygroundEditor"],
"output": "public/js/sandbox.min.js"
}
}
}
}
assegai wc:build --group=site assegai wc:list --group=sandbox --json assegai wc:watch --group=site --group=sandbox
Omit --group to select all configured groups. Without webComponents.groups, the existing src/**/*.wc.ts discovery and single-bundle paths are unchanged. Grouped discovery visits only the selected sources; files outside the configured groups are excluded. Paths are relative to the workspace. Source memberships cannot overlap, and artifact paths must stay in the workspace without conflicting with another group or source path. Importing a different group's .wc.ts component is rejected. Shared ordinary TypeScript/CSS dependencies are allowed.
Each group owns its configured JavaScript output and the sibling .css output emitted by esbuild. A stylesheet no longer emitted is removed. Cache files are separate under .cache/assegai/groups/<name>/: wc-entry.ts, web-components.manifest.json, and esbuild-meta.json. The metafile is esbuild's dependency graph, including transitive input paths and emitted outputs relative to the workspace. Building one group leaves unselected groups' files unchanged. Compiler/runtime builds and deployment uploads remain separate application workflows.
Watch mode detects new, removed and renamed components, including the first component in an empty source directory. It checks directory membership at the configured hot-reload polling interval using the existing watch tick. Esbuild tracks dependency content edits. Successful builds update per-group hot-reload markers and the existing root marker, so Core's existing browser poller observes changes to any selected group. For a configured marker public/.assegai/wc-hot-reload.json, group markers live at public/.assegai/groups/<name>/wc-hot-reload.json.
One watch session coordinates the selected groups and stops its children together. Build locks prevent concurrent writers to the same group; another group can be built independently. serve --dev watches all configured groups. --no-hot-reload retains watch builds without writing browser markers. CLI command failures return a nonzero exit code.
Custom schematics
You can extend the generator without forking the CLI.
The default local convention is:
schematics/<name>/
schematic.json
templates/
Start with a declarative starter:
assegai schematic:init loyalty-program
Or scaffold a PHP-backed starter when generation needs real logic:
assegai schematic:init customer-portal --php
Inspect what the CLI discovered:
assegai schematic:list
Run a custom schematic through the normal generate workflow:
assegai g loyalty-program rewards
For reusable team schematics, package manifests can be exposed through composer.json:
{
"extra": {
"assegai": {
"schematics": [
"resources/loyalty/schematic.json"
]
}
}
}
Learn more in the official documentation.
Stay in touch
- Author - Andrew Masiye, Daniel Kaluba
- Website - https://assegaiphp.com
- X - @assegaiphp
License
Assegai Console is MIT Licensed
