1. Go to this page and download the library: Download ekuiter/feature-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ekuiter / feature-php example snippets
/*
* This is a simple example for the usage of the feature-php library.
* Here we are going to analyze a given feature model regarding a given configuration.
* Then, for a valid configuration, we analyze the generated product.
* Finally, the user may export a ZIP file and download it.
*
* Feature models and configurations are expected to be supplied as
* FeatureIDE XML files, see https://featureide.github.io/.
* The product line settings can be supplied in various formats, see
* the feature-php API reference.
*/
use \FeaturePhp as fphp; // this is just for convenience so we can abbreviate the prefix "FeaturePhp\" below
he configuration is user-supplied with the GET or POST parameter "configuration"
// we could also use XmlConfiguration::fromString(...) or XmlConfiguration::fromFile(...)
if (isset($_REQUEST["configuration"]))
$configuration = new fphp\Model\Configuration(
$productLine->getModel(),
fphp\Model\XmlConfiguration::fromRequest("configuration")
);
else // if not supplied, use the default configuration
$configuration = $productLine->getDefaultConfiguration();
// used for replacements by the templating system
fphp\Specification\ReplacementRule::setConfiguration($configuration);
if (!isset($_REQUEST["generate"])) {
// output some information on the model and configuration
echo '<h2><a href="?generate">Generate</a></h2>';
echo $configuration->renderAnalysis();
} else {
// we want to generate or export a product
$product = $productLine->getProduct($configuration);
if (!isset($_REQUEST["export"])) {
// output some information on the product
echo '<h2><a href="?generate&export">Download ZIP</a></h2>';
echo $product->renderAnalysis();
} else
// export product as ZIP file (using "tmp" as a temporary directory)
$product->export(new fphp\Exporter\DownloadZipExporter("tmp"));
}
} catch (Exception $e) {
echo $e->getMessage();
}