Comments (2)
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.
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)
- support sendFile and sendStreamAsFile for Response HOT 3
- Memory leaks due to repeating `str_pad()` in `yii\base\ErrorHandler::register()` method HOT 9
- yidas/yii2-bower-asset This won't be necessary HOT 3
- roadrunner configuration files .rr.yaml according to https://github.com/yiisoft/yii-runner-roadrunner/ HOT 2
- route inoperative HOT 4
- Ability to disable sessions HOT 1
- Bug in Application->handleError HOT 1
- URLManager Parameters not available in yii\web\Request::getQueryParams() HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-psr7-bridge.