Download the PHP package slendium/compositor without Composer
On this page you can find all versions of the php package slendium/compositor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download slendium/compositor
More information about slendium/compositor
Files in slendium/compositor
Package compositor
Short Description A framework-agnostic library for generating (hyper)text documents from a component tree.
License MIT
Informations about the package compositor
Slendium Compositor
A framework-agnostic PHP library for generating (hyper)text documents from a component tree.
- PHPDoc type annotations for static analyzers with a clear distinction between literal and non-literal strings, the latter of which are automatically escaped
- Two-phase mechanism: expensive operations can be aggregated before the (hyper)text is generated
- Composition-based, does not depend on inheritance or on global state
- Track the resources (JS/CSS) needed for the components used
- Reusability of components
Installation
Requires PHP >= 8.5. Simply run composer install slendium/compositor to add the base functionality
to your project. See also:
- slendium/common-components - a package that defines some common HTML components for the compositor
- slendium/slendium-static - a static site generator
Examples
Basic example
The example is a bit contrived (in real world code a component would be designed differently), but it shows how components only need to declare what to display in two cases (object found or not found) and don't need to know about database queries or caches. Additionally it shows how the entire tree can be generated dynamically without requiring complex initialization to ensure all objects are present.