Skip to content

Instantly share code, notes, and snippets.

<?php
use React\Http\Server;
use React\Http\Response;
use React\EventLoop\Factory;
use Psr\Http\Message\ServerRequestInterface;
$loop = Factory::create();
<?php
function (ServerRequestInterface $request, \React\EventLoop\LoopInterface $loop) {
$childProcess = new \React\ChildProcess\Process('cat pages/index.html');
$childProcess->start($loop);
return new React\Http\Response(200, ['Content-Type' => 'text/html'], $childProcess->stdout);
}
<?php
use React\EventLoop\Factory;
use React\Filesystem\Filesystem;
use function React\Promise\Stream\unwrapWritable;
require __DIR__ . '/../../vendor/autoload.php';
$loop = Factory::create();
$filesystem = Filesystem::create($loop);
const http = require('http');
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello world');
});
server.listen('8000', '127.0.0.1');
@seregazhuk
seregazhuk / describe_workflow.php
Created March 26, 2022 19:52
Example of using DescribeWorkflowExecutionRequest
<?php
$workflowClient = WorkflowClient::create(ServiceClient::create($host));
$workflow = $workflowClient->newUntypedWorkflowStub(MyWorkflow::class);
$workflowClient->start($workflow);
$describeWorkflowExecutionRequest = new DescribeWorkflowExecutionRequest();
$describeWorkflowExecutionRequest->setNamespace('default');
$describeWorkflowExecutionRequest->setExecution($workflow->getExecution()->toProtoWorkflowExecution());
@seregazhuk
seregazhuk / wokflow.php
Last active June 24, 2022 17:15
Workflow
<?php
declare(strict_types=1);
use Carbon\CarbonInterval;
use Temporal\Activity\ActivityOptions;
use Temporal\Common\RetryOptions;
use Temporal\Internal\Workflow\ActivityProxy;
use Temporal\Workflow;