Installation guide
Questi contenuti non sono ancora disponibili nella tua lingua.
System requirements
Section titled “System requirements”- PHP
8.3or higher. - Composer
2.3or higher (the plugin requirescomposer-plugin-api^2.3). - Symfony Console
^7.4or^8.0, installed as a dependency. Symfony Console 8 requires PHP 8.4, so a project on PHP 8.3 resolves 7.4. - php-forge/diff, installed as a dependency, which renders the unified diffs with Git’s default algorithm (Myers with the indent heuristic).
The plugin is framework-agnostic: it works in any project managed by Composer.
Install the plugin
Section titled “Install the plugin”Scaffolding is a development-time task, so require the plugin in require-dev and allow it to run:
composer config allow-plugins.php-forge/scaffold truecomposer require --dev php-forge/scaffold:^0.3The equivalent composer.json configuration is:
{ "require-dev": { "php-forge/scaffold": "^0.3" }, "config": { "allow-plugins": { "php-forge/scaffold": true } }}Without the allow-plugins entry, Composer asks whether to trust the plugin, and non-interactive runs such as CI fail.
Authorize providers
Section titled “Authorize providers”Require the provider packages and list, in order, the ones allowed to write files into the project. Packages that are not listed are ignored.
composer require --dev php-forge/baseline php-forge/coding-standard{ "extra": { "scaffold": { "allowed-packages": ["php-forge/baseline", "php-forge/coding-standard"] } }}Run composer install or composer update. The plugin applies the files of every listed provider, writes
scaffold-lock.json, and ends with a summary line on stdout:
[scaffold] 10 files written, 1 unchanged, 1 warning.Warnings, such as an existing file that the first install overwrote, are printed on stderr above it; see
File Modes. Review the result with git diff.
Commit the lock file
Section titled “Commit the lock file”scaffold-lock.json records which provider owns each file, how it was written and the hashes of the last apply. Commit
it with the scaffolded files, so every clone and CI job detects user-modified files and provider updates the same way:
git add scaffold-lock.jsonComposer flags
Section titled “Composer flags”The plugin listens to Composer events as a plugin, not as a script:
| Command | Scaffolds? |
|---|---|
composer install | Yes. |
composer install --no-scripts | Yes: --no-scripts disables scripts, not plugin event subscribers. |
composer install --no-plugins | No: the plugin is not loaded. Run vendor/bin/scaffold sync afterwards. |
composer install --no-dev | No, on a fresh install: the plugin in require-dev is not installed. |
Any command with "auto": false | No: run vendor/bin/scaffold sync when you want to apply the providers. |
Manual mode with auto: false
Section titled “Manual mode with auto: false”To review every change to the shared files before it lands, disable the Composer hooks and apply the providers with the console:
{ "extra": { "scaffold": { "auto": false, "allowed-packages": ["php-forge/baseline", "php-forge/coding-standard"] } }}Composer runs then print
[scaffold] Auto-scaffold disabled via "extra.scaffold.auto"; run "vendor/bin/scaffold" manually. Bootstrap the project
with sync, which also creates scaffold-lock.json:
$ vendor/bin/scaffold status...[scaffold] 10 files: 10 pending.$ vendor/bin/scaffold sync --dry-run --exit-code...[scaffold] sync --dry-run: 10 files would change, 0 unchanged, 0 orphan, 0 errors.$ vendor/bin/scaffold sync[scaffold] sync: 10 files written, 0 unchanged.Run vendor/bin/scaffold sync again after each provider update.
Invoke the console
Section titled “Invoke the console”The plugin installs a standalone console application at vendor/bin/scaffold; it starts from Composer’s autoloader and
needs no framework bootstrap:
vendor/bin/scaffold list # available commandsvendor/bin/scaffold status # state of every scaffolded filevendor/bin/scaffold diff --all # what applying the providers would changeSee Console Commands for every command and option.