I want to use R inside PHP using php-r. As I am very new to PHP, I would be very grateful if anyone guides me on how to install php-r inside xampp and run the same.
I tried putting the PHPR directory inside htdocs and accessed it from php using
<?php
use Kachkaev/PHPR/RCore;
use Kachkaev/PHPR/Engine/CommandLineREngine;
$r = new RCore(new CommandLineREngine('/usr/bin/R'));
$result = $r->run(<<<EOF
x = 1
y = 2
x + y
x + z
x - y
EOF
);
echo $result;
?>
This returns an error
Fatal error: Class 'Kachkaev\PHPR\RCore' not found in /opt/lampp/htdocs/testserver/test.php on line 6
N.B: My R is installed in /usr/bin/R
composer require kachkaev/php-ris the easiest way to install php-r