Code Monkey home page Code Monkey logo

Comments (2)

totoropy avatar totoropy commented on September 26, 2024 1

You are right.

Here is an updated worker:

use Nyholm\Psr7;
use Spiral\Goridge\StreamRelay;
use Spiral\RoadRunner;

// Roadrunner relay and PSR7 object
$relay = new StreamRelay(STDIN, STDOUT);
$worker = new RoadRunner\Worker($relay);

$psrFactory = new Psr7\Factory\Psr17Factory();
$psr7 = new RoadRunner\Http\PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);

// Load your configuration file
$config = require __DIR__ . '/config/main.php';
$application = (new \yii\Psr7\web\Application($config));

// Handle each request in a loop
while ($request = $psr7->waitRequest()) {
	try {
		$response = $application->handle($request);
		$psr7->respond($response);
	}
	catch (\Throwable $e) {
		// \yii\Psr7\web\ErrorHandler should handle any exceptions
		// however you should implement your custom error handler should anything slip past.
		$psr7->getWorker()->error((string)$e);
	}

	// Workers will steadily grow in memory with each request until PHP memory_limit is reached, resulting in a worker crash.
	// With RoadRunner, you can tell the worker to shutdown if it approaches 10% of the maximum memory limit, allowing you to achieve better uptime.
	if ($application->clean()) {
		$psr7->getWorker()->stop();
		return;
	}
}

from yii2-psr7-bridge.

charlesportwoodii avatar charlesportwoodii commented on September 26, 2024

This library just adapts the Yii2 request/response objects to PSR7. It should work just fine with rr 2.1 with an updated worker.

I don't have a rr 2.1 worker example on hand, but it should be trivial to adapt the 1.8 worker outlined in the README to 2.1 by following the API specification for both this library and rr.

Let me know once you give it a try if the README needs to be updated. Pull requests are always welcome.

from yii2-psr7-bridge.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.