Skip to content

Examples ​

Each example is a small PHP project in examples/: a composer.json, a run.php that builds a form and prints the HTML, and expected-output.txt with that HTML. Each page shows the code, a preview of the HTML with Bootstrap 3.4.1 CSS and the HTML itself.

Running an example ​

All examples need PHP 8.4 or newer and Composer. They do not need a web server, a database or a network connection except for composer install:

bash
git clone https://github.com/tomaj/nette-bootstrap-form.git
cd nette-bootstrap-form/examples/layouts
composer install
php run.php

Until 3.0.0 is tagged, the examples require tomaj/nette-bootstrap-form: dev-master with "minimum-stability": "dev" and "prefer-stable": true; after the release they switch to ^3.0.

How the examples are tested ​

The Examples workflow runs every example on each push and pull request:

  1. examples/ci/example.sh <name> copies the example to a temporary directory.
  2. examples/ci/use-local-bootstrap-form.sh adds the repository root as a Composer path repository, installs the package from it and fails if vendor/ holds anything else. So a pull request runs the examples against its own code.
  3. php run.php prints the HTML, which must be byte for byte the same as expected-output.txt (diff -u).

The previews on these pages are built from the same expected-output.txt files when the site is built (docs/scripts/previews.mjs), so a preview always shows the HTML that CI has checked. Run an example against your checkout with examples/ci/example.sh layouts; after an intended change in the output, examples/ci/example.sh --update layouts writes the new expected-output.txt.

The PHP snippets on the other pages of this site are run by tests/DocsSnippetsTest.php in the PHPUnit suite, and their documented output is compared too.

Released under the MIT License.