PHP code example of elevenways / doen

1. Go to this page and download the library: Download elevenways/doen 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/ */

    

elevenways / doen example snippets



// You will need an event loop instance.
// If this looks weird to you, you should lookup ReactPHP
$loop = \React\EventLoop\Factory::create();

// Now we can create a Doen instance
$doen = new \Elevenways\Doen\Doen($loop);

// Lets get our first, simple reference
// $libpath is now an \Elevenways\Doen\Reference instance
$libpath = $doen->evaluateToRef('t starts the event loop and will BLOCK the rest of the code!
$loop->run();

$libpath = $doen->

$promise = $doen->evaluate('1 + 1');

$promise = $doen->evaluate('function(a, b) {return a * b}', [3, 2]);

$libpath = $doen->evaluateToRef('

$doen->close();

$ref = $doen->evaluateToRef('1 + 1');
$ref->getValue(function($result) {
    // Outputs: 2
    echo $result;
});

$ref = $doen->evaluateToRef('1 + 1');
$ref->then(function($type) {
    // Outputs: "number"
    echo $type;
});

$array = $doen->evaluateToRef('[]');
$ref->then(function($type) {
    // Outputs: "Array"
    echo $type;
});

$ref = $doen->evaluateToRef('1 + 1');
$ref->__monkeyPatch('weird', function() {
    return 'weird';
});

// Returns "weird"
$ref->weird();