Skip to content

[NFR]: Project commands #8

Description

@niden

Goal: create a new ADR project with one command, and run it with docker or with PHP on the host.

Today a developer writes the front controller, public/index.php, composer.json and the docker files by hand. devtools had project for this. Crest replaces devtools, so it needs the same.

  • new <name> [--namespace=App] [--php=8.4] [--phalcon=v5] [--force] : scaffold an ADR project from stubs
  • up [--build] : docker compose up -d
  • down [--volumes] : docker compose down
  • install : docker compose exec app composer install
  • repl : interactive shell with the project container loaded (devtools console, shell, psysh). Needs a design first.

new

Writes eleven files: ten new stubs plus the existing action.stub.

my-app/
├── composer.json
├── crest.php
├── .env
├── .gitignore
├── .htrouter.php
├── README.md
├── docker-compose.yml
├── resources/docker/Dockerfile
├── public/index.php
└── src/
    ├── AppFront.php
    └── Action/Get.php
  • Generated from stubs, the same as every make:* command. stub:publish makes every file editable.
  • Runs nothing: no composer, no docker, no network. Either the tree is written or it is not.
  • composer.json is a stub. --phalcon=v5 requires ext-phalcon: ^5. --phalcon=v6 requires phalcon/phalcon: ^6.0.
  • --php takes major.minor only. --phalcon takes v5 or v6 only. Other values are rejected.
  • <name> is the directory, not the namespace. It is validated as a name, not a path.
  • A non-empty target is refused unless --force is given.
  • The project commits to one Phalcon variant. The Dockerfile keeps only ARG PHP_VERSION. A comment shows the two edits that switch the variant.
  • The container serves on port 8080: php -S 0.0.0.0:8080 -t public .htrouter.php.
  • new does not extend ProjectCommand. No project exists yet, so it writes crest.php and does not read it.
  • The seed action is a fixed App\Action\Get. Convention cannot name it, because there is no vendor/ yet.
  • ADR only. Other flavors add their own stub set later.

Closing output. The generated files are the same on every host. Only this text shows both paths:

Created my-app/

Nothing runs it yet. With docker:

    cd my-app
    crest up
    crest install

Or with PHP and composer on the host:

    cd my-app
    composer install
    crest serve

Then GET / answers from src/Action/Get.php

Until serve exists, the host path prints php -S directly.

up, down, install

  • Thin wrappers for docker compose. Crest wrote the compose file, so it owns the app service name.
  • New Crest\Process\Runner interface, with ShellRunner as the default. Injected the same way as ActionResolver.
  • A missing docker binary reports as a normal crest error, not a PHP warning.

Done when

  • Every generated PHP file parses and its imports resolve.
  • Config::discover() reads the generated crest.php.
  • Project\Bootstrap::container() boots the generated front controller. No docker needed.
  • up, down and install are tested with a fake runner that asserts the exact argv.
  • Name validation and refuse-unless---force are tested, as for every generator.

A manual end-to-end run (generate, install, send a request) is a release check. It is not part of this issue.

Out of scope

  • The global install (composer global require phalcon/crest) that lets new, up, down and install run before a project exists. It is part of the release work.
  • serve. It has its own issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

  • Status
    Implemented

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions