sy / project
Project template
Requires
- php: >=8.1
- sy/bootstrap: ^3.1
Requires (Dev)
- phpunit/phpunit: ^13
- sy/coding-standard: *
- sy/flyway: *
- sy/genini: *
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 8.3.0
- 8.2.3
- 8.2.2
- 8.2.1
- 8.2.0
- 8.1.0
- 8.0.0
- 7.1.0
- 7.0.2
- 7.0.1
- 7.0.0
- 6.6.1
- 6.6.0
- 6.5.1
- 6.5.0
- 6.4.11
- 6.4.10
- 6.4.9
- 6.4.8
- 6.4.7
- 6.4.6
- 6.4.5
- 6.4.4
- 6.4.3
- 6.4.2
- 6.4.1
- 6.4.0
- 6.3.1
- 6.3.0
- 6.2.1
- 6.2.0
- 6.1.4
- 6.1.3
- 6.1.2
- 6.1.1
- 6.1.0
- 6.0.0
- 5.5.6
- 5.5.5
- 5.5.4
- 5.5.3
- 5.5.2
- 5.5.1
- 5.5.0
- 5.4.1
- 5.4.0
- 5.3.0
- 5.2.6
- 5.2.5
- 5.2.4
- 5.2.3
- 5.2.2
- 5.2.1
- 5.2.0
- 5.1.0
- 5.0.0
- 4.8.0
- 4.7.3
- 4.7.2
- 4.7.1
- 4.7.0
- 4.6.6
- 4.6.5
- 4.6.4
- 4.6.3
- 4.6.2
- 4.6.1
- 4.6.0
- 4.5.0
- 4.4.1
- 4.4.0
- 4.3.0
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.0
- 3.5.1
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.1
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.1
- 3.0.0
- 2.3.0
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.1.1
- 1.1.0
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.0.1
- dev-develop
This package is auto-updated.
Last update: 2026-12-02 16:07:31 UTC
README
A skeleton to start a new website. Build with sy/bootstrap
Requirements
- PHP 8.1+
- Docker, for the asset build:
extra.sy.buildskips itself (exit 0) when the current user is not in thedockergroup, so a machine without Docker can still install and deploy
Installation
Start a new project with
composer create-project sy/project [DIRECTORY]
Composer scripts
The project lifecycle is one command, wired to the three Composer events that can happen on an install or an update:
"post-create-project-cmd": ["@sy install"], "post-install-cmd": ["@sy install"], "post-update-cmd": ["@sy install"]
vendor/bin/sy is shipped by sy/bootstrap. sy install is idempotent: every
configuration file that is missing is generated, the plugin files are copied
when absent and refreshed when their vendor copy is newer, and the Sass build
and the migrations run only when they are actually needed. Nothing is
remembered in a state file — every decision is derived from the filesystem.
| Command | Effect |
|---|---|
composer create-project sy/project [DIRECTORY] |
Installs the dependencies, then runs sy install: creates the writable directories, asks for the missing INI files, builds the assets, migrates the database. |
composer install |
Installs the dependencies, then sy install. |
composer update |
Updates the dependencies, then sy install. |
composer require sy/bootstrap-<plugin>[:version] |
Installs the plugin, then sy install runs through post-update-cmd. |
composer sy <verb> |
Any installer verb directly: install, plan, sync, build, db, doctor. |
composer sy plan |
Abbreviation of composer sy install dry-run: prints every command instead of running it. |
protected/vendor/bin/sy <verb> |
The same installer, without Composer: flags are not intercepted, which is what a deploy script needs. |
composer sy db [task] |
Flyway on the core schema and on every plugin schema. migrate by default; info, repair, clean, validate and baseline are accepted. |
composer sy build |
Rebuilds the CSS and JS assets on demand. |
composer sy doctor |
Exits non zero when a plugin file or assets/css/app.css is missing. A missing protected/conf/*.ini, or a declared writable directory that is missing or closed to the web server, is only a warning: the next install fixes it. |
composer format, composer check |
PHP_CodeSniffer fixer and checker. |
composer test |
Runs the project suite with PHPUnit: composer test [FILE OR DIRECTORY]. |
Migration to 3.0
sy/bootstrap 3.0.0 deletes the Sy\Bootstrap\Plugin class: the lifecycle only
runs through bin/sy, and the Composer hooks must call the script instead of a
PHP callback.
| 1.x / 2.x wiring | 3.0 wiring |
|---|---|
"post-install-cmd": ["Sy\Bootstrap\Plugin::installPlugins"] |
"post-install-cmd": ["@sy install"] |
"post-update-cmd": ["Sy\Bootstrap\Plugin::dbMigrateIfConfigured"] |
"post-update-cmd": ["@sy install"] |
"post-create-project-cmd": ["Sy\Bootstrap\Plugin::installProjectFirst"] |
"post-create-project-cmd": ["@sy install"] |
"post-package-install" / "post-package-update" → Plugin::postPackageInstall |
remove both, they no longer exist and copied nothing on a deploy where no version changed |
"sy": "@php protected/vendor/bin/sy" |
unchanged, and the only alias besides the developer tools |
Two things make the jump safe to prepare: a project on ^2 never receives 3.0
through an ordinary composer update, and composer install-plugin <name>
becomes composer require sy/bootstrap-<name> (the hook then runs @sy install).
A project that still wires the per-package events will fail its next
composer install with a class-not-found error — that is the intended signal,
and the fix is the table above.
Migration from 7.x
| 7.x command | 8.0.0 command |
|---|---|
composer install-project |
composer sy install |
composer install-plugin <plugin> [version] |
composer require sy/bootstrap-<plugin>[:version] |
composer db [task] |
composer sy db [task] |
composer build |
composer sy build |
composer doctor |
composer sy doctor |
The installer modifiers are positional and apply to every verb: dry-run,
quiet, no-build, no-db, no-templates. Composer would consume the --
form before it reaches the installer — composer sy install --dry-run silently
runs a real install — so it is only accepted on a direct call.
composer sy install dry-run # print the commands, run nothing composer sy db info dry-run # same modifier, any verb composer sy install quiet # no output, exit code only composer sy plan # abbreviation of `install dry-run` composer sy install no-build no-db # files only composer sy db info # positional task, no separator needed protected/vendor/bin/sy install --dry-run # direct call: flags are kept as-is
Tests
The skeleton ships PHPUnit 13; a project only adds tests under protected/tests/.
The configuration lives in the test script itself, so there is no phpunit.xml
to keep in sync:
"test": "XDEBUG_MODE=coverage phpunit --bootstrap protected/tests/bootstrap.php --coverage-text --coverage-filter protected/src protected/tests"
composer test # the whole suite composer test -- --filter SmokeTest # one class composer test -- --filter testTheAutoloader # one method
Options go after --: Composer consumes the ones it knows before they reach
PHPUnit. The suite path is part of the script, so an extra path would be run in
addition to it — to run a single file, call PHPUnit directly:
protected/vendor/bin/phpunit --bootstrap protected/tests/bootstrap.php protected/tests/SmokeTest.php
protected/tests/bootstrap.php loads the Composer autoloader, plus
protected/conf/conf.php once the project is installed. A fresh clone — or a
CI job that runs before sy install — therefore still runs every test that does
not need the configuration, and the ones that do call markTestSkipped() with the
reason.
| Where | What belongs there |
|---|---|
protected/tests/ (Project\Tests\, PSR-4) |
the behaviour this project wires: services, pages, forms, URL converters, components |
| the framework packages | the generic mechanism (routing, containers, cache, HTML policy…), each tested in its own repository |
Coverage is part of the script, filtered on protected/src — the code this
project owns. The XDEBUG_MODE=coverage prefix enables the driver for that one
process, so composer test is green without any shell preparation. On a machine
with no coverage driver at all, call PHPUnit without the coverage flags:
protected/vendor/bin/phpunit --bootstrap protected/tests/bootstrap.php protected/tests
Configuration
Everything lives in composer.json, under extra.sy:
"extra": { "sy": { "build": "if ! id -nG \"$USER\" | grep -qw docker; then echo \"build skipped: $USER is not in the docker group\" >&2; exit 0; fi; docker run --pull always --rm -v \"$PWD\":/syproject -w /syproject node:24-slim sh -c 'if [ -f package-lock.json ]; then npm ci; else npm install; fi; npm install -g gulp-cli; gulp build' && sudo chown -R \"$USER\" assets && sudo find . -maxdepth 1 \\( -name node_modules -o -name package-lock.json \\) -exec chown -R \"$USER\" {} +", "writable": ["@LOG_DIR", "@UPLOAD_DIR"], "ini": { "database": { "file": "protected/conf/database.ini", "input": { … } }, "smtp": { "file": "protected/conf/smtp.ini", "input": { … } } } } }
buildis the shell command compiling the project assets; it runs in the project root whenassets/css/app.cssis missing —protected/scss/app.scssalways needs compiling — or when a plugin SCSS file is newer than it. The shipped command skips itself with exit 0 when$USERis not in thedockergroup, installs frompackage-lock.json(npm ci) when a lock exists, pinsnode:24-sliminstead of a moving tag, and gives the files Docker created back to the current user (chownonassets/,node_modules,package-lock.json). A build interrupted before thatchownleaves root-owned files: reclaim them withsudo chown -R "$USER" assets node_modules package-lock.json— the oldcomposer chowndid the same over.,protected/logandupload/included, and took those back fromwww-data;inilists the configuration filesgeninigenerates when they are missing, with the questions asked to the developer. The skeleton declares six database questions (host,port,dbname,username,password,charset) and five SMTP ones (host,port,username,password,encryption); theinputmaps are shortened above;writablelists the project directories the web server writes into. The installer runs as you while PHP-FPM runs aswww-data: a directory it created would stay0755, and the application could not createLOG_DIR/app.loginside it — the first write then printsWarning: mkdir(): Permission deniedinto the page, followed by itsCannot modify header informationcascade.sy installcreates those directories0777, and only those: unlike the oldinstall-projectscript, it never runs a recursivechmod -R a+w .and never opensprotected/conf/*.ini;@LOG_DIRand@UPLOAD_DIRare not paths but project constants:sy installreads them fromprotected/conf/conf.php, whereindex.phpand the upload code already read them. Move a constant (shared volume, nested directory, test layout) and the installer follows — no path is copied intocomposer.json. Anything that resolves outside the project is left to the server administrator;install— absent from the skeleton — lists shell commands run once, just after the INI generation, so a latersy installdoes nothing: the place for a seed script.
Add an entry to ini for a project-specific file, a path to writable for a
directory the web server writes into, and a command to install for anything
genini cannot express.
Plugin files
sy install applies the same rules to every installed plugin
(vendor/sy/bootstrap-*):
assets/are copied, or refreshed when the vendor copy is newer;templates/are copied only when the file is missing: once copied, a template belongs to the project and is never overwritten;- the Sass build runs only when a plugin ships
scss/(or a.scssfile undertemplates/), and only whenassets/css/app.cssis older than every plugin SCSS file; - the migrations run per plugin schema, each with its own
flyway_<plugin>_historytable.
composer sy doctor is the cheapest way to check a deployment: it exits non zero
when a plugin asset is missing from the project, which is exactly the failure a
git clean or a stale deploy produces.
Create configuration files
The installer guides you through these files: each entry of extra.sy.ini is
asked for when the file is missing, on the first composer install (or
composer sy install).
Create the file [DOCUMENT ROOT]/protected/conf/database.ini
Example:
host = localhost
port = 3306
dbname = mydatabase
username = myuser
password = mypassword
charset = utf8mb4
Create the file [DOCUMENT ROOT]/protected/conf/smtp.ini
Example:
host = smtp.gmail.com
username = user@example.com
password = mypassword
port = 587
encryption = tls
Create database
When a new project is created, the database is created with this SQL script: protected/sql/V1__init.sql
We use Flyway to manage database changes. Here is the composer custom command:
composer sy db [task]
Flyway commands:
- migrate
- info
- repair
- clean
- validate
- baseline
Example:
composer sy db migrate
Build CSS & JS
We have a composer custom command for building CSS and JS assets:
composer sy build
But it's recommended to install NodeJS and Gulp if you have to rebuild frequently the CSS or JS.
Go to the project folder and install project dependencies
npm install
To build css (protected/scss/app.scss -> assets/css/app.css)
gulp css
To build js (protected/js/*.js -> assets/js/app.js)
gulp js
Check/format PHP coding style
Check the coding style
composer check [FILE or DIRECTORY]
Format the coding style
composer format [FILE or DIRECTORY]
Example:
composer format protected/src
Coding standard ruleset used: sy/coding-standard