-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PHP]: hleb2-workerman added (#8042)
* [PHP]: hleb2-workerman added * [PHP]: fix hleb2-workerman * [PHP]: hleb2-workerman - update workerman version
- Loading branch information
Showing
12 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Bootstrap; | ||
|
||
use Hleb\Constructor\Containers\CoreContainer; | ||
|
||
final class BaseContainer extends CoreContainer implements ContainerInterface | ||
{ | ||
#[\Override] | ||
final public function get(string $id): mixed | ||
{ | ||
return parent::get($id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Bootstrap; | ||
|
||
use Hleb\Constructor\Containers\BaseContainerFactory; | ||
|
||
final class ContainerFactory extends BaseContainerFactory | ||
{ | ||
#[\Override] | ||
public static function rollback(): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Bootstrap; | ||
|
||
use Hleb\Constructor\Containers\CoreContainerInterface; | ||
|
||
interface ContainerInterface extends CoreContainerInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"require": { | ||
"php": ">=8.2.0", | ||
"phphleb/framework": "~2.0.0", | ||
"workerman/workerman": "@stable" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"app/" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
framework: | ||
website: hleb2framework.ru | ||
github: phphleb/hleb | ||
version: 2.0 | ||
|
||
files: | ||
- console | ||
|
||
bootstrap: | ||
- php console --generate-key | ||
- php console --routes-upd | ||
|
||
engines: | ||
- workerman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
return [ | ||
'debug' => false, | ||
'log.enabled' => false, | ||
'max.log.level' => 'info', | ||
'max.cli.log.level' => 'info', | ||
'log.level.in-cli' => false, | ||
'error.reporting' => E_ALL, | ||
'log.sort' => true, | ||
'log.stream' => false, | ||
'log.format' => 'row', | ||
'log.db.excess' => 0, | ||
'timezone' => 'UTC', | ||
'routes.auto-update' => false, | ||
'container.mock.allowed' => false, | ||
'app.cache.on' => false, | ||
'show.request.id' => false, | ||
'max.log.size' => 0, | ||
'max.cache.size' => 0, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
return [ | ||
'base.db.type' => 'mysql.name', | ||
'db.settings.list' => [] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
return [ | ||
'default.lang' => 'en', | ||
'allowed.languages' => ['en'], | ||
'session.enabled' => false, | ||
'db.log.enabled' => false, | ||
'session.options' => [], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
return [ | ||
'project.paths' => ['logs' => '/storage/logs'], | ||
'classes.autoload' => true, | ||
'origin.request' => false, | ||
'ending.slash.url' => 0, | ||
'ending.url.methods' => ['get'], | ||
'url.validation' => false, | ||
'session.name' => 'PHPSESSID', | ||
'max.session.lifetime' => 0, | ||
'allowed.route.paths' => [], | ||
'allowed.structure.parts' => [], | ||
'page.external.access' => true, | ||
'module.dir.name' => 'modules', | ||
'custom.function.files' => [], | ||
'custom.setting.files' => [], | ||
'events.used' => false, | ||
'async.clear.state' => false, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
define('HLEB_PUBLIC_DIR', realpath(__DIR__ . '/public')); | ||
|
||
require realpath(__DIR__ . '/vendor/phphleb/framework/console.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Workerman\Worker; | ||
use Workerman\Connection\TcpConnection; | ||
use Workerman\Protocols\Http\Response; | ||
|
||
include __DIR__ . "/../vendor/autoload.php"; | ||
|
||
$framework = new Hleb\HlebAsyncBootstrap(__DIR__); | ||
|
||
$server = new Worker( 'http://0.0.0.0:3000'); | ||
|
||
$server->count = shell_exec('nproc') ?: 32; | ||
|
||
$server->onMessage = function (TcpConnection $connection, $request) use ($framework) { | ||
$res = $framework->load($request)->getResponse(); | ||
|
||
$connection->send(new Response($res->getStatus(), $res->getHeaders(), $res->getBody())); | ||
}; | ||
|
||
Worker::runAll(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
Route::get('/', ''); | ||
Route::get('/user/{id}', preview('{%id%}')); | ||
Route::post('/user', ''); |