phpgt / build
Client-side build system for PHP projects.
Fund package maintenance!
Requires
- php: >=8.2
- ext-json: *
- composer/semver: v3.*
- phpgt/cli: ^1.4
- phpgt/sync: ^1.3
- webmozart/glob: v4.4.*
Requires (Dev)
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.1
- squizlabs/php_codesniffer: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-20 11:27:03 UTC
README
This project provides a system for defining and running client-side build processes automatically, using tools already installed by your favourite client-side dependency manager.
Example usage
An example build.json below shows three different usages:
npmhas been used to install babel into the node_modules directory. The command to run is thebabelbinary within the node_modules directory. The command will execute whenever a*.es6file changes within the script directory.sasshas been installed to the system. Thesasscommand is available on the environment PATH, and the developer has stated that at least version 3.5 is required for the build. The command will execute whenever a*.scssfile changes within the style directory.- A custom PHP script is called whenever any HTML or PHP file is edited in the page directory. This assumes that the command
vendor/bin/sitemapis installed via a composer package.
build.json:
{
"script/**/*.es6": {
"name": "Babel transpile",
"command": "./node_modules/.bin/babel",
"args": "script/main.js -o www/script.js",
"require": {
"node": "^8.4",
"@command": "^6.0"
}
},
"style/**/*.scss": {
"name": "Sass compilation",
"command": "sass",
"args": "style/main.scss www/style.css",
"require": {
"@command": ">=3.5"
}
},
"page/**/*.{html|php}": {
"name": "Sitemap generation",
"command": "php vendor/bin/sitemap",
"args": "src/page www/sitemap.xml"
}
}
Installing client-side packages
For projects with a package.json, the build runner checks direct dependencies with
npm ls --json --depth=0 --include=dev before checking build requirements. Missing
packages or versions that do not satisfy package.json trigger npm install --include=dev automatically, with progress shown in the terminal. Installation
must succeed and satisfy the dependency check before the build continues.
Extraneous packages alone do not trigger installation. This checks installed
dependencies, rather than whether npm install has ever been run; it does not
validate every transitive dependency or compare the installation against a lockfile.
The project's node_modules/.bin is added to PATH during the build, so commands
such as webpack and sass can use their locally installed binaries.
Install Node.js and npm first. See npm's installation documentation for installing the packages declared by your project. Missing build commands and installation failures include these links in the terminal.
Projects without a package.json continue to use their chosen dependency manager
and installed tools without invoking npm.
Features at a glance
- One-off builds
- Background builds (watching the matching files and re-building where necessary)
- Bring your own client-side dependency manager