PHP code example of kachkaev / php-r-bundle

1. Go to this page and download the library: Download kachkaev/php-r-bundle 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/ */

    

kachkaev / php-r-bundle example snippets


// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Kachkaev\PHPRBundle\KachkaevPHPRBundle(),
        // ...
    );
}

$r = $container->get('kachkaev_phpr.core');
$rResult = $r->run('x = 10
x * x');

// --- or ---

$r = $container->get('kachkaev_phpr.core');
$rProcess = $r->createInteractiveProcess();
$rProcess->write('x = 10');
$rProcess->write('x * x');
$rResult = $rProcess->getAllResult();

$rOutputParser = $container->get('kachkaev_phpr.output_parser');

$rProcess->write('21 + 21');
var_dump($rProcess->getLastWriteOutput());
// string(6) "[1] 42"
var_dump($rOutputParser->singleNumber($rProcess->getLastWriteOutput()));
// int(42)
js
    "  // ...
        "kachkaev/php-r-bundle": "dev-master"
        // ...
    }
bash
$ php composer.phar update kachkaev/php-r-bundle