Fork me on GitHub

Example: the calculator


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.

The HTML code.

<div <?= attr()->bind(rq(App\Calculator\Calc::class)) ?>>
    <?= cl(App\Calculator\Calc::class)->html() ?>
</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'));