Fork me on GitHub

Exemple : la calculatrice


In this example, a calculator is implemented as a Jaxon component, which is inserted at a given position in the page.

The result of the operation is computed by a service which is injected in the main component, and formatted by another component.

Le code est décrit plus en détails dans la documentation de la librairie.

The HTML code.

<div <?= attr()->bind(App\Calculator\Calc::class) ?>>
    <?= attr()->html(App\Calculator\Calc::class) ?>
</div>

The calculator components

The Jaxon library config

The calculator service

The Jaxon setup code.

<?php

$loader = new Keradus\Psr4Autoloader;
$loader->register();

// Register the namespace with a third-party autoloader
$loader->addNamespace('Service\\Calculator', ajaxDir('/calculator/lib'));
// Load the config
jaxon()->app()->setup(configFile('calculator.php'));