From bf1d614f4545b0bfbc9bd04a14bfcf035b69c3e0 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Thu, 6 Oct 2022 03:02:34 +0000 Subject: [PATCH 1/2] chore: add support for eien --- src/App.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/App.php b/src/App.php index e754104..e56d751 100755 --- a/src/App.php +++ b/src/App.php @@ -414,4 +414,30 @@ public function cors($options = []) trigger_error('Cors module not found! Run `composer require leafs/cors` to install the CORS module. This is required to configure CORS.'); } } + + /** + * @inheritdoc + */ + public static function run(?callable $callback = null) + { + if (class_exists('Leaf\Eien\Server')) { + // this entire part can be added to the run method of the app class + // This would mean that no part of the user's app would be changed + // They just install eien and reap immediete benefits + + server() + ->wrap(function () use ($callback) { + \ob_start(); + parent::run($callback); + ob_end_clean(); + + return Config::get('response.data'); + }) + ->listen(function ($server) { + echo "Leaf Eien server started on http://127.0.0.1:{$server->port}"; + }); + } else { + return parent::run($callback); + } + } } From ecc287db3795f77620ecadcb59e10427de37eb00 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Sat, 8 Oct 2022 15:18:42 +0000 Subject: [PATCH 2/2] chore: add support for eien --- src/App.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/App.php b/src/App.php index e56d751..516e50f 100755 --- a/src/App.php +++ b/src/App.php @@ -421,21 +421,11 @@ public function cors($options = []) public static function run(?callable $callback = null) { if (class_exists('Leaf\Eien\Server')) { - // this entire part can be added to the run method of the app class - // This would mean that no part of the user's app would be changed - // They just install eien and reap immediete benefits - server() ->wrap(function () use ($callback) { - \ob_start(); parent::run($callback); - ob_end_clean(); - - return Config::get('response.data'); }) - ->listen(function ($server) { - echo "Leaf Eien server started on http://127.0.0.1:{$server->port}"; - }); + ->listen(); } else { return parent::run($callback); }