Skip to content

Commit

Permalink
chore: add support for eien
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Oct 6, 2022
1 parent 7f25664 commit bf1d614
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit bf1d614

Please sign in to comment.