iqual / project-scaffold
Interactive project scaffolding and initializing.
Package info
github.com/iqual-ch/project-scaffold
Type:composer-plugin
pkg:composer/iqual/project-scaffold
Requires
- php: ^8.3
- composer-plugin-api: ^2.6
- symfony/yaml: ^6.4 || ^7.0
- twig/twig: ^3.9.3
Requires (Dev)
- composer/composer: ^2.6
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.5 || ^11.0
- symfony/process: ^6.4 || ^7.0
README
A Composer plugin that scaffolds and updates project files from versioned asset packages.
Files that usually get copied from project to project by hand — CI workflows, .ddev or .devcontainer setups, .env templates, .gitignore, Makefiles — can instead be defined once in an asset package and managed by Composer. When the package is required, updated or used with composer create-project, the plugin places the files, renders templates and, if run interactively, asks the questions the package defines and saves the answers to the project's composer.json.
The plugin is heavily inspired by Drupal's drupal/core-composer-scaffold, generalized beyond Drupal. Credit to its contributors.
How it works
An asset package declares its files under extra.project-scaffold.assets, grouped by operation:
add— created once, never overwritten.replace— kept in sync on every update; an empty source deletes the destination.merge— values are merged into existing.env, line-based (.gitignore), JSON and YAML files, preserving local additions and comments.read— a questions definition; missing or newly asked variables are prompted interactively and written back to the rootcomposer.json.
Sources ending in .twig are rendered with the project's variables before being placed. See creating a project asset package for the full format.
The root project stays in control: it can ignore individual files, disable automatic scaffolding, force a hard re-scaffold or preview changes with a dry run. See controlling scaffolding in the root project.
Getting started
composer require iqual/project-scaffold --dev
Allow the plugin when Composer asks, then require one or more asset packages. The plugin prompts for the package's questions, saves the answers under extra.project-scaffold and scaffolds the files. From then on, composer update keeps the managed files up to date.
Commands
| Command | Purpose |
|---|---|
composer project:init |
Prompt all package questions again and re-apply the scaffolding. |
composer project:update |
Alias of project:init. |
composer project:scaffold |
Re-apply the scaffolding without prompting. |
Scaffolding also runs automatically after composer install, update, require and create-project.
Both commands accept a --force flag for a hard re-scaffold and a --dry-run flag to preview changes, and the automatic scaffolding can be disabled — see controlling scaffolding in the root project.
Versions
| Branch | Requirements | Status |
|---|---|---|
2.x |
PHP ^8.3, Composer 2.6+ |
Active development |
1.x |
PHP >= 7.3 | Critical fixes only |
Development
The test suite runs offline against fixture projects, locally via ddev (ddev start, then make install and make test) or any PHP >= 8.3 (composer test). See testing.