Example #1
0
function do_undeploy($deployId, $count)
{
    Vertx::undeployVerticle($deployId, function () {
        $count++;
        if ($count < 10) {
            do_deploy($count);
        } else {
            Vertx::logger()->info('Done!');
        }
    });
}
Example #2
0
function copyMods()
{
    Vertx::fileSystem()->copyRecursive("src/test/resources/includemod/mods", "target/mods", function ($error) {
        if ($error) {
            Vertx::logger()->error($error);
            return;
        } else {
            Vertx::deployModule('io.vertx~php-includetest-mod~v1.0', NULL, 1, function ($id, $error) {
                if ($error) {
                    Vertx::logger()->error($error);
                    return;
                } else {
                    TestRunner::run(new IncludeTestCase());
                    Vertx::undeployModule($id);
                }
            });
        }
    });
}
Example #3
0
<?php

use Vertx\Buffer;
$client = Vertx::createNetClient();
$logger = Vertx::logger();
$client->connectTimeout = 30;
$client->connect(1234, NULL, function ($socket, $error) use($logger) {
    if (!$error) {
        $buffer = new Buffer();
        $socket->dataHandler(function ($buffer) use($logger) {
            $logger->info("Client receiving " . $buffer);
            $buffer->appendBuffer($buffer);
        });
        for ($i = 0; $i < 10; $i++) {
            $message = "Hello {$i}.";
            $logger->info("Client sending " . $message);
            $socket->write($message);
        }
    } else {
        $logger->info("Failed to connect to the server. " . $error->getMessage());
    }
});
Example #4
0
<?php

Vertx::logger()->info('Config is ' . var_dump(Vertx::config()));
Example #5
0
<?php

require_vertx("hello-lib.php");
$eventBus = Vertx::eventBus();
Vertx::logger()->info(sayHello("User"));
/**
 * Test if the require_vertx really loads php files of other module ressources
 * if they are included
 */
$eventBus->registerHandler('test.require_vertx', function ($message) {
    $message->reply(sayHello("Test"));
});
/**
 * test if the Autoclassloader is using the Vertx Classloader to load
 * internal classes
 */
$eventBus->registerHandler('test.autoload.internal', function ($message) {
    $helloObject = new InternalHelloClass("Test");
    $message->reply($helloObject->sayHello());
});
/**
 * test if the Autoclassloader is using the Vertx ClassLoader, so it can find
 * included module classes
 */
$eventBus->registerHandler('test.autoload.external', function ($message) {
    $helloObject = new lib\ExternalHelloClass("Test");
    $message->reply($helloObject->sayHello());
});