Skip to content

Commit

Permalink
2023.04.16 Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
monkenWu committed Apr 16, 2023
2 parents b7afc0b + f492913 commit 90f7bd8
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# CodeIgniter4-Burner

<p align="center">
<a href="https://burner.monken.tw/">
<a href="https://ciburner.com/">
<img src="https://i.imgur.com/YI4RqdP.png" alt="logo" width="200" />
</a>
</p>

Burner is an out-of-the-box library for CodeIgniter4 that supports [RoadRunner](https://roadrunner.dev/), [Workerman](https://github.com/walkor/workerman), and [OpenSwoole](https://openswoole.com/) high-performance web servers. All you need to do is open a few php extensions to dramatically speed up your CodeIgniter4 applications, allowing them to handle higher loads and more connections at the same time.

[English Document](https://burner.monken.tw/en/introduction)
[English Document](https://ciburner.com//en/introduction)

[正體中文簡介](README_zh-TW.md)

Expand Down
4 changes: 2 additions & 2 deletions README_zh-TW.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Codeigniter4-Burner

<p align="center">
<a href="https://burner.monken.tw/">
<a href="https://ciburner.com/">
<img src="https://i.imgur.com/YI4RqdP.png" alt="logo" width="200" />
</a>
</p>

Burner 是一款專屬於 CodeIgniter4 的開箱即用的程式庫,它支援 [RoadRunner](https://roadrunner.dev/) , [Workerman](https://github.com/walkor/workerman) 與 , [OpenSwoole](https://openswoole.com/) 高效能網頁伺服器。你只需要開啟一些 php 擴充套件,即可大幅度地加速你的 CodeIgniter4 應用程式,使其能承受更高的負載並同時處理更多的連線。

[正體中文文件](https://burner.monken.tw/zh_TW/introduction)
[正體中文文件](https://ciburner.com/zh_TW/introduction)

## 安裝

Expand Down
3 changes: 1 addition & 2 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function run(ServerRequestInterface $request, bool $isWebsocket =
{
// handle request object
try {
$ci4Request = RequestHandler::initRequest($request, 'workerman');
$ci4Request = RequestHandler::initRequest($request);
} catch (Throwable $e) {
dump((string) $e);
}
Expand Down Expand Up @@ -119,7 +119,6 @@ public static function clean()
self::resetServices();
Factories::reset();
HandleConnections::close(self::$config);
unset($_SERVER['HTTP_X_FORWARDED_FOR'], $_SERVER['HTTP_X_REAL_IP'], $_SERVER['HTTP_USER_AGENT']);
UploadedFileBridge::reset();
}

Expand Down
15 changes: 1 addition & 14 deletions src/Bridge/RequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ public static function initRequest(ServerRequestInterface $rRequest)
$appConfig = new App();
self::$_rRequest = $rRequest;
self::setFile();
self::setServer();

Services::createRequest($appConfig, false);
Services::request()->getUserAgent()->parse($_SERVER['HTTP_USER_AGENT']);
Services::request()->getUserAgent()->parse(self::$_rRequest->getHeaderLine('User-Agent'));

UriBridge::setUri(self::$_rRequest->getUri());

// $rRequest->g
Services::request()->setBody(self::getBody());

self::setParams();
Expand All @@ -35,17 +33,6 @@ public static function initRequest(ServerRequestInterface $rRequest)
return Services::request();
}

protected static function setServer()
{
$_SERVER['HTTP_USER_AGENT'] = self::$_rRequest->getHeaderLine('User-Agent');
if (self::$_rRequest->getHeaderLine('x-forwarded-for') !== '') {
$_SERVER['HTTP_X_FORWARDED_FOR'] = self::$_rRequest->getHeaderLine('x-forwarded-for');
}
if (self::$_rRequest->getHeaderLine('x-real-ip') !== '') {
$_SERVER['HTTP_X_REAL_IP'] = self::$_rRequest->getHeaderLine('x-real-ip');
}
}

protected static function setFile()
{
if (self::$_rRequest->getUploadedFiles() !== []) {
Expand Down
10 changes: 5 additions & 5 deletions src/Bridge/UploadedFileBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ public static function getPsr7UploadedFiles(
): array {
if (! (self::$_instance instanceof UploadedFileBridge)) {
if ($isBurner) {
$isWorkerMan = false;
$needNewInstance = false;
$check = reset($files);
if (is_array($check)) {
$isWorkerMan = true;
$needNewInstance = true;
$multiCheck = reset($check);
if ($multiCheck instanceof \Psr\Http\Message\UploadedFileInterface) {
$isWorkerMan = false;
$needNewInstance = false;
}
}
self::$_instance = new UploadedFileBridge(
$files,
$isBurner,
// is WorkerMan files?
$isWorkerMan
// is need new file instance ?
$needNewInstance
);
} else {
self::$_instance = new UploadedFileBridge();
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/InitLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function run(array $params)

protected function publishBurnerConfig(string $driver)
{
$basePath = ROOTPATH . 'app/Config' . DIRECTORY_SEPARATOR;
$basePath = APPPATH . 'Config' . DIRECTORY_SEPARATOR;
$configPath = $basePath . 'Burner.php';

if (file_exists($configPath)) {
Expand Down
4 changes: 1 addition & 3 deletions src/FrontLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
exit;
}

$paths = 'app/Config/Paths.php';

require_once realpath($vendorPath . 'autoload.php');
$pathsConfig = realpath($vendorPath . '../app/Config/Paths.php');
$pathsConfig = realpath( APPPATH . '/Config/Paths.php');
// Path to the front loader (this file)
defined('FCPATH') || define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);
chdir(FCPATH);
Expand Down

0 comments on commit 90f7bd8

Please sign in to comment.