1. Go to this page and download the library: Download innmind/homeostasis 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/ */
innmind / homeostasis example snippets
use function Innmind\Homeostasis\bootstrap;
use Innmind\Homeostasis\{
Factor,
Factor\Cpu,
Factor\Log,
Sensor\Measure\Weight,
};
use Innmind\OperatingSystem\Factory;
use Innmind\Url\Path;
use Innmind\Math\{
Polynom\Polynom,
Algebra\Integer
Algebra\Number\Number,
};
use Innmind\LogReader\{
Reader\OnDemand,
Log as LogLine,
};
use Innmind\Immutable\Set;
use Psr\Log\LogLevel;
$os = Factory::build();
$clock = $os->clock();
$homeostasis = bootstrap(
Set::of(
Factor::class,
new Cpu(
$clock,
$os->status(),
new Weight(new Number(0.5)),
(new Polynom)->withDegree(new Integer(1), new Integer(1))
),
new Log(
$clock,
new OnDemand(new Symfony($clock)),
$os->filesystem()->mount(Path::of('var/logs')),
new Weight(new Number(0.5)),
(new Polynom)->withDegree(new Integer(1), new Integer(1)),
static function(LogLine $line): bool {
return $line->attributes()->contains('level') &&
$line->attributes()->get('level')->value() === LogLevel::CRITICAL;
},
'symfony',
),
),
/*you need to implement the Actuator interface*/,
$os->filesystem()->mount(Path::of('some/path/to/store/states')),
$clock,
);
$modulateStateHistory = $homeostasis['modulate_state_history'](
$os->filesystem()->mount(Path::of('some/path/to/store/actions')),
);
$regulate = $modulateStateHistory(
$homeostasis['regulator'],
);
$regulate();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.