phug / split
Pug (ex-Jade) facade engine for PHP, HTML template engine structured by indentation
Fund package maintenance!
kylekatarnls
Open Collective
Tidelift
Requires
- php: ^7.3 || ^8.0
- ext-json: *
- simple-cli/simple-cli: ^1.6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15.0 || ^3.23.0
- nette/utils: ^3.2.10
- phan/phan: ^3.2.10 || ^5.4.2
- phpmd/phpmd: ^2.13.0
- phpstan/phpstan: ^0.11.15 || ^1.10.29
- phpunit/phpunit: ^8.5.33 || ^9.6.11
- squizlabs/php_codesniffer: ^3.7.2
- vimeo/psalm: ^4.30.0 || ^5.14.1
README
Split is a tool to handle a mono-repo that can be downloaded as single package, multiple packages or both.
Install
composer require phug/split
Usage
Put composer.json files in sub-directory of a main package repository.
vendor/bin/split update
Check options with:
vendor/bin/split update --help
Check other commands with:
vendor/bin/split --help
Passing GIT authentication via environment variables:
Export env var such as:
REPOSITORY_CREDENTIALS=my-git-username:my-authentication-token
vendor/bin/split update --git-credentials=$REPOSITORY_CREDENTIALS
Example
phug-php/phug is a library that can be required either entirely with phug/phug
or as separated packages
phug/parser
, phug/compiler
, etc.
Each package is defined by a directory in src/Phug with a dedicated composer.json
file inside each of them.
Once you created a GitHuba (or other git publisher) repository, and registered each of them on packagist.org (you can submit repository with just a single composer.json file with basic infos, the split will insert the actual content later).
You can now simply run from the monorepository the vendor/bin/split update
or run this automatically from a hook or a job.
For instance phug/phug
uses GitHub Actions to trigger it automatically after each commit:
.github/workflows/split.yml
It relies on very few steps:
-
Load PHP via
shivammathur/setup-php@v2
-
Cache dependencies folder with
actions/cache@v2
to make the job faster (optional) -
Install
phug/split
with:test -f composer.json && mv composer.json composer.json.save -f composer require phug/split --no-interaction test -f composer.json.save && mv composer.json.save composer.json -f
(
mv
commands are optional, it's here to install onlyphug/split
as your other dependencies are not needed for this job) -
Run the
split update
command- name: Split monorepository run: vendor/bin/split update --git-credentials=$REPOSITORY_CREDENTIALS env: REPOSITORY_CREDENTIALS: ${{ secrets.REPOSITORY_CREDENTIALS }}
Here we pass git credentials using the
git-credentials
as the job runner will not have an authenticaed git user able to push to your repositories.The authentication variable is you git username, followed by
:
, followed by an authentication token you can generate via the page https://github.com/settings/tokens (See documentation: Managing your personal access tokens).Don't put this clear token directly in the GitHub Action file, use a repository secret (See documentation: Encrypted secrets) to keep it private.