From d9b19c2fa584351e22947800abde34470e4e8095 Mon Sep 17 00:00:00 2001 From: Petrik Date: Sat, 5 Apr 2025 21:53:10 +0200 Subject: [PATCH] [php/sw-sf-less] Remove sw-sf-less sw-sf-less has been tagged as broken for 2 years. The repo hasn't been updated in 3 years: https://github.com/luoxiaojun1992/sw-fw-less There also is a 5 year old open issue about abandoned dependencies: https://github.com/luoxiaojun1992/sw-fw-less/issues/6 --- frameworks/PHP/sw-fw-less/.env | 8 -- frameworks/PHP/sw-fw-less/.gitignore | 6 - frameworks/PHP/sw-fw-less/README.md | 51 -------- .../PHP/sw-fw-less/app/models/Fortune.php | 10 -- .../PHP/sw-fw-less/app/models/World.php | 10 -- .../sw-fw-less/app/services/TestService.php | 121 ------------------ .../PHP/sw-fw-less/benchmark_config.json | 31 ----- frameworks/PHP/sw-fw-less/composer.json | 44 ------- frameworks/PHP/sw-fw-less/config.toml | 19 --- frameworks/PHP/sw-fw-less/config/app.php | 88 ------------- .../PHP/sw-fw-less/config/coroutine.php | 6 - frameworks/PHP/sw-fw-less/config/events.php | 40 ------ frameworks/PHP/sw-fw-less/config/log.php | 11 -- .../PHP/sw-fw-less/config/middleware.php | 18 --- frameworks/PHP/sw-fw-less/config/mysql.php | 23 ---- .../PHP/sw-fw-less/config/providers.php | 30 ----- frameworks/PHP/sw-fw-less/config/router.php | 15 --- frameworks/PHP/sw-fw-less/config/server.php | 23 ---- frameworks/PHP/sw-fw-less/start.php | 12 -- .../PHP/sw-fw-less/sw-fw-less.dockerfile | 33 ----- 20 files changed, 599 deletions(-) delete mode 100644 frameworks/PHP/sw-fw-less/.env delete mode 100644 frameworks/PHP/sw-fw-less/.gitignore delete mode 100644 frameworks/PHP/sw-fw-less/README.md delete mode 100644 frameworks/PHP/sw-fw-less/app/models/Fortune.php delete mode 100644 frameworks/PHP/sw-fw-less/app/models/World.php delete mode 100644 frameworks/PHP/sw-fw-less/app/services/TestService.php delete mode 100755 frameworks/PHP/sw-fw-less/benchmark_config.json delete mode 100644 frameworks/PHP/sw-fw-less/composer.json delete mode 100644 frameworks/PHP/sw-fw-less/config.toml delete mode 100644 frameworks/PHP/sw-fw-less/config/app.php delete mode 100644 frameworks/PHP/sw-fw-less/config/coroutine.php delete mode 100644 frameworks/PHP/sw-fw-less/config/events.php delete mode 100644 frameworks/PHP/sw-fw-less/config/log.php delete mode 100644 frameworks/PHP/sw-fw-less/config/middleware.php delete mode 100644 frameworks/PHP/sw-fw-less/config/mysql.php delete mode 100644 frameworks/PHP/sw-fw-less/config/providers.php delete mode 100644 frameworks/PHP/sw-fw-less/config/router.php delete mode 100644 frameworks/PHP/sw-fw-less/config/server.php delete mode 100644 frameworks/PHP/sw-fw-less/start.php delete mode 100644 frameworks/PHP/sw-fw-less/sw-fw-less.dockerfile diff --git a/frameworks/PHP/sw-fw-less/.env b/frameworks/PHP/sw-fw-less/.env deleted file mode 100644 index a1f35255fd2..00000000000 --- a/frameworks/PHP/sw-fw-less/.env +++ /dev/null @@ -1,8 +0,0 @@ -## MySQL -MYSQL_DSN="mysql:dbname=hello_world;host=tfb-database;port=3306" -MYSQL_USERNAME=benchmarkdbuser -MYSQL_PASSWD=benchmarkdbpass -MYSQL_POOL_SIZE=10 -MYSQL_SWITCH=1 -MYSQL_POOL_CHANGE_EVENT=0 -MYSQL_REPORT_POOL_CHANGE=0 \ No newline at end of file diff --git a/frameworks/PHP/sw-fw-less/.gitignore b/frameworks/PHP/sw-fw-less/.gitignore deleted file mode 100644 index 588e36cc131..00000000000 --- a/frameworks/PHP/sw-fw-less/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/vendor/ -/.idea -/.idea/ -/runtime -/runtime/ -/composer.lock \ No newline at end of file diff --git a/frameworks/PHP/sw-fw-less/README.md b/frameworks/PHP/sw-fw-less/README.md deleted file mode 100644 index 949cce2368e..00000000000 --- a/frameworks/PHP/sw-fw-less/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# [Sw-Fw-Less](https://github.com/luoxiaojun1992/sw-fw-less) Benchmarking Test - -This is the [Sw-Fw-Less](https://github.com/luoxiaojun1992/sw-fw-less) portion of a [benchmarking test suite](../) comparing a variety of web development platforms. - -### JSON Encoding Test - -* [JSON test source](app/services/TestService.php) - -### Plaintext Test - -* [Plaintext test source](app/services/TestService.php) - -### Data-Store/Database Mapping Test - -* [DB test controller](app/services/TestService.php) -* [DB test model](app/models/World.php) - -### Fortunes Test -* [Fortunes test controller](app/services/TestService.php) -* [Fortunes test model](app/models/Fortune.php) - - -## Infrastructure Software Versions -The tests were run with: -* [PHP 7.4](https://www.php.net/) -* [Swoole v4.5.6](https://www.swoole.com/) - -## Test URLs -### JSON Encoding Test - -http://localhost:9501/json - -### Plaintext Test - -http://localhost:9501/plaintext - -### Data-Store/Database Mapping Test - -http://localhost:9501/db - -### Variable Query Test - -http://localhost:9501/queries/2 - -### Data Updates Test - -http://localhost:9501/updates/2 - -### Fortunes Test - -http://localhost:9501/fortunes diff --git a/frameworks/PHP/sw-fw-less/app/models/Fortune.php b/frameworks/PHP/sw-fw-less/app/models/Fortune.php deleted file mode 100644 index 50d37a727b5..00000000000 --- a/frameworks/PHP/sw-fw-less/app/models/Fortune.php +++ /dev/null @@ -1,10 +0,0 @@ - 'Hello, World!']; - } - - public function db() - { - $world = World::select()->cols(['*'])->where('`id` = :id') - ->bindValue(':id', random_int(1, 10000)) - ->first(); - - return $world ? $world->toArray() : []; - } - - public function queries($queries = 1) - { - $queries = $this->clamp($queries); - - $rows = []; - while ($queries--) { - $row = World::select()->cols(['*'])->where('`id` = :id') - ->bindValue(':id', random_int(1, 10000)) - ->first(); - $rows[] = $row ? $row->toArray() : []; - } - - return $rows; - } - - public function fortunes() - { - $rows = Fortune::select()->cols(['*'])->get(); - - $insert = new Fortune(); - $insert->id = 0; - $insert->message = 'Additional fortune added at request time.'; - - $rows[] = $insert; - - usort($rows, function ($left, $right) { - return strcmp($left->message, $right->message); - }); - - return Response::output($this->renderFortunes($rows), 200, ['Content-Type' => 'text/html;charset=utf-8']); - } - - private function renderFortunes($fortunes) - { - $html = << - -Fortunes - - - - - %s -
idmessage
- - -EOF; - - $fortuneRows = ''; - foreach ($fortunes as $fortune) { - $fortuneRows .= ' ' . htmlspecialchars($fortune->id) . - '' . htmlspecialchars($fortune->message) . '' . PHP_EOL; - } - - return sprintf($html, $fortuneRows); - } - - public function updates($queries = 1) - { - $queries = $this->clamp($queries); - - $rows = []; - - while ($queries--) { - $row = World::select()->cols(['*'])->where('`id` = :id') - ->bindValue(':id', random_int(1, 10000)) - ->first(); - if ($row) { - $row->randomNumber = random_int(1, 10000); - $row->save(); - - $rows[] = $row->toArray(); - } else { - $rows[] = []; - } - } - - return $rows; - } - - public function plaintext() - { - return Response::output('Hello, World!', 200, ['Content-Type' => 'text/plain']); - } - - private function clamp($value): int - { - if (! is_numeric($value) || $value < 1) { - return 1; - } - if ($value > 500) { - return 500; - } - return (int)$value; - } -} diff --git a/frameworks/PHP/sw-fw-less/benchmark_config.json b/frameworks/PHP/sw-fw-less/benchmark_config.json deleted file mode 100755 index 5274a2a7268..00000000000 --- a/frameworks/PHP/sw-fw-less/benchmark_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "framework": "sw-fw-less", - "tests": [ - { - "default": { - "json_url": "/json", - "db_url": "/db", - "query_url": "/queries/", - "fortune_url": "/fortunes", - "update_url": "/updates/", - "plaintext_url": "/plaintext", - "port": 9501, - "approach": "Realistic", - "classification": "Micro", - "database": "MySQL", - "framework": "Sw-Fw-Less", - "language": "PHP", - "flavor": "None", - "orm": "Full", - "platform": "swoole", - "webserver": "None", - "os": "Linux", - "database_os": "Linux", - "display_name": "Sw-Fw-Less", - "notes": "", - "versus": "swoole", - "tags": ["broken"] - } - } - ] -} diff --git a/frameworks/PHP/sw-fw-less/composer.json b/frameworks/PHP/sw-fw-less/composer.json deleted file mode 100644 index 90e38601f9a..00000000000 --- a/frameworks/PHP/sw-fw-less/composer.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "luoxiaojun/sw-fw-less-app", - "description": "Swoole Http Server App", - "type": "project", - "keywords": [ - "swoole", - "framework", - "coroutine", - "php", - "app" - ], - "require": { - "php": ">=7.1", - "ext-json": "*", - "ext-pdo": "*", - "ext-swoole": ">=4.4.0", - "luoxiaojun/sw-fw-less": "dev-master" - }, - "suggest": { - "ext-redis": "*" - }, - "license": "apache-2.0", - "authors": [ - { - "name": "luoxiaojun", - "email": "luoxiaojun1992@sina.cn" - } - ], - "autoload": { - "psr-4": {"App\\": "app/"} - }, - "scripts": { - "post-root-package-install": [ - "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" - ] - }, - "config": { - "sort-packages": true, - "optimize-autoloader": true, - "preferred-install": "dist" - }, - "minimum-stability": "dev", - "prefer-stable": true -} diff --git a/frameworks/PHP/sw-fw-less/config.toml b/frameworks/PHP/sw-fw-less/config.toml deleted file mode 100644 index 4c03bee7d3d..00000000000 --- a/frameworks/PHP/sw-fw-less/config.toml +++ /dev/null @@ -1,19 +0,0 @@ -[framework] -name = "sw-fw-less" - -[main] -urls.plaintext = "/plaintext" -urls.json = "/json" -urls.db = "/db" -urls.query = "/queries/" -urls.update = "/updates/" -urls.fortune = "/fortunes" -approach = "Realistic" -classification = "Micro" -database = "MySQL" -database_os = "Linux" -os = "Linux" -orm = "Full" -platform = "swoole" -webserver = "None" -versus = "swoole" diff --git a/frameworks/PHP/sw-fw-less/config/app.php b/frameworks/PHP/sw-fw-less/config/app.php deleted file mode 100644 index 9c497c3b7af..00000000000 --- a/frameworks/PHP/sw-fw-less/config/app.php +++ /dev/null @@ -1,88 +0,0 @@ - [ - 'origin' => env('CORS_ORIGIN', ''), - 'switch' => envInt('CORS_SWITCH', 0), - ], - - //Timezone - 'timezone' => env('TIMEZONE', null), - - //Monitor - 'monitor' => [ - 'switch' => envInt('MONITOR_SWITCH', 0), - ], - - //Throttle - 'throttle' => [ - 'metric' => function(\SwFwLess\components\http\Request $request){ - return $request->getRoute(); - }, - 'period' => envInt('THROTTLE_PERIOD', 60), - 'throttle' => envInt('THROTTLE_THROTTLE', 10000), - ], - - //RedLock - 'red_lock' => [ - 'connection' => env('RED_LOCK_CONNECTION', 'red_lock'), - ], - - //RateLimit - 'rate_limit' => [ - 'connection' => env('RATE_LIMIT_CONNECTION', 'rate_limit'), - ], - - //Cache - 'cache' => [ - 'connection' => env('CACHE_CONNECTION', 'cache'), //redis connection - 'update_lock_ttl' => envInt('CACHE_UPDATE_LOCK_TTL', 10), - ], - - //Hot Reload - 'hot_reload' => [ - 'switch' => envInt('HOT_RELOAD_SWITCH', 0), - 'watch_dirs' => [ - __DIR__ . '/', - __DIR__ . '/../app/', - __DIR__ . '/../vendor/', - __DIR__ . '/../', - ], - 'excluded_dirs' => [], - 'watch_suffixes' => ['.php', '.env'], - 'driver' => env('HOT_RELOAD_DRIVER', \Kwf\FileWatcher\Watcher::class), //HuangYi\Watcher\Watcher::class is another choice - ], - - //Error handler - 'error_handler' => [ - 'err_formatter' => function (\Throwable $e) { - return nl2br($e->getMessage() . PHP_EOL . $e->getTraceAsString()); - }, - ], - - //Ip Restriction - 'ip_restriction' => [ - 'ips' => env('IP_RESTRICTION_IPS'), - 'api_prefix' => env('IP_RESTRICTION_API_PREFIX'), - ], - - //Scheduler - 'scheduler' => [ -// [ -// 'schedule' => '* * * * *', -// 'jobs' => function () { -// echo 'Every minute', PHP_EOL; -// }, -// ], -// [ -// 'schedule' => '*/2 * * * *', -// 'jobs' => function () { -// echo 'Every two minutes', PHP_EOL; -// }, -// ], - ], - - //You can turn off the switch to improve the performance - 'route_di_switch' => envBool('ROUTE_DI_SWITCH', false), -]; diff --git a/frameworks/PHP/sw-fw-less/config/coroutine.php b/frameworks/PHP/sw-fw-less/config/coroutine.php deleted file mode 100644 index ca102cdcbcc..00000000000 --- a/frameworks/PHP/sw-fw-less/config/coroutine.php +++ /dev/null @@ -1,6 +0,0 @@ - envInt('COROUTINE_PREEMPTIVE_SCHEDULER', 0), - 'hook_flags' => SWOOLE_HOOK_ALL, -]; diff --git a/frameworks/PHP/sw-fw-less/config/events.php b/frameworks/PHP/sw-fw-less/config/events.php deleted file mode 100644 index c81f2ce7605..00000000000 --- a/frameworks/PHP/sw-fw-less/config/events.php +++ /dev/null @@ -1,40 +0,0 @@ - [ - function (\Cake\Event\Event $event) { - $count = $event->getData('count'); - - if (\SwFwLess\components\Config::get('redis.report_pool_change')) { - \SwFwLess\components\swoole\counter\Counter::incr('monitor:pool:redis', $count); - } - }, - ], - \SwFwLess\components\mysql\MysqlPool::EVENT_MYSQL_POOL_CHANGE => [ - function (\Cake\Event\Event $event) { - $count = $event->getData('count'); - - if (\SwFwLess\components\Config::get('mysql.report_pool_change')) { - \SwFwLess\components\swoole\counter\Counter::incr('monitor:pool:mysql', $count); - } - }, - ], - \SwFwLess\components\amqp\ConnectionPool::EVENT_AMQP_POOL_CHANGE => [ - function (\Cake\Event\Event $event) { - $count = $event->getData('count'); - - if (\SwFwLess\components\Config::get('amqp.report_pool_change')) { - \SwFwLess\components\swoole\counter\Counter::incr('monitor:pool:amqp', $count); - } - }, - ], - \SwFwLess\components\hbase\HbasePool::EVENT_HBASE_POOL_CHANGE => [ - function (\Cake\Event\Event $event) { - $count = $event->getData('count'); - - if (\SwFwLess\components\Config::get('hbase.report_pool_change')) { - \SwFwLess\components\swoole\counter\Counter::incr('monitor:pool:hbase', $count); - } - }, - ], -]; diff --git a/frameworks/PHP/sw-fw-less/config/log.php b/frameworks/PHP/sw-fw-less/config/log.php deleted file mode 100644 index 3e3a8b8f500..00000000000 --- a/frameworks/PHP/sw-fw-less/config/log.php +++ /dev/null @@ -1,11 +0,0 @@ - env('LOG_PATH', __DIR__ . '/../runtime/logs/app-{date}.log'), - 'level' => envInt('LOG_LEVEL', \Monolog\Logger::DEBUG), - 'pool_size' => envInt('LOG_POOL_SIZE', 100), - 'buffer_max_size' => envInt('LOG_BUFFER_MAX_SIZE', 10), - 'name' => env('LOG_NAME', 'sw-fw-less'), - 'reserve_days' => envInt('LOG_RESERVE_DAYS', 3), - 'switch' => envInt('LOG_SWITCH', 0), -]; diff --git a/frameworks/PHP/sw-fw-less/config/middleware.php b/frameworks/PHP/sw-fw-less/config/middleware.php deleted file mode 100644 index bc4dc44ae4c..00000000000 --- a/frameworks/PHP/sw-fw-less/config/middleware.php +++ /dev/null @@ -1,18 +0,0 @@ - [ -// \SwFwLess\components\zipkin\Middleware::class, -// \SwFwLess\components\chaos\Middleware::class, -// \SwFwLess\middlewares\Cors::class, -// \SwFwLess\components\auth\Middleware::class, -// \SwFwLess\middlewares\IpRestriction::class, - ], - 'routeMiddleware' => [ -// \SwFwLess\components\ratelimit\Middleware::class, - ], - 'aliases' => [ - 'cors' => \SwFwLess\middlewares\Cors::class, - 'auth' => \SwFwLess\components\auth\Middleware::class, - ], -]; diff --git a/frameworks/PHP/sw-fw-less/config/mysql.php b/frameworks/PHP/sw-fw-less/config/mysql.php deleted file mode 100644 index 33d4d727ea8..00000000000 --- a/frameworks/PHP/sw-fw-less/config/mysql.php +++ /dev/null @@ -1,23 +0,0 @@ - env('MYSQL_DEFAULT', 'default'), - 'connections' => [ - env('MYSQL_DEFAULT', 'default') => [ - 'dsn' => env('MYSQL_DSN', 'mysql:dbname=sw_test;host=127.0.0.1'), - 'username' => env('MYSQL_USERNAME', 'root'), - 'passwd' => env('MYSQL_PASSWD', null), - 'options' => [ - \PDO::ATTR_CASE => \PDO::CASE_NATURAL, - \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, - \PDO::ATTR_ORACLE_NULLS => \PDO::NULL_NATURAL, - \PDO::ATTR_STRINGIFY_FETCHES => false, - \PDO::ATTR_EMULATE_PREPARES => false, - ], - 'pool_size' => envInt('MYSQL_POOL_SIZE', 5), - ], - ], - 'switch' => envInt('MYSQL_SWITCH', 0), - 'pool_change_event' => envInt('MYSQL_POOL_CHANGE_EVENT', 0), - 'report_pool_change' => envInt('MYSQL_REPORT_POOL_CHANGE', 0), -]; diff --git a/frameworks/PHP/sw-fw-less/config/providers.php b/frameworks/PHP/sw-fw-less/config/providers.php deleted file mode 100644 index 8e885a94ac4..00000000000 --- a/frameworks/PHP/sw-fw-less/config/providers.php +++ /dev/null @@ -1,30 +0,0 @@ - [ - ['GET', '/json', [TestService::class, 'json']], - ['GET', '/db', [TestService::class, 'db']], - ['GET', '/queries/[{queries}]', [TestService::class, 'queries']], - ['GET', '/fortunes', [TestService::class, 'fortunes']], - ['GET', '/updates/[{queries}]', [TestService::class, 'updates']], - ['GET', '/plaintext', [TestService::class, 'plaintext']], - ], - 'group' => [], -]; diff --git a/frameworks/PHP/sw-fw-less/config/server.php b/frameworks/PHP/sw-fw-less/config/server.php deleted file mode 100644 index c90bd44d5fc..00000000000 --- a/frameworks/PHP/sw-fw-less/config/server.php +++ /dev/null @@ -1,23 +0,0 @@ - env('SERVER_HOST', '0.0.0.0'), - 'port' => envInt('SERVER_PORT', 9501), - 'worker_num' => envInt('SERVER_WORKER_NUM', swoole_cpu_num() * 2), - 'daemonize' => envBool('SERVER_DAEMONIZE', false), - 'backlog' => envInt('SERVER_BACKLOG', 128), - 'max_request' => envInt('SERVER_MAX_REQUEST', 0), - 'dispatch_mode' => envInt('SERVER_DISPATCH_MODE', 2), - 'open_http2_protocol' => envBool('SERVER_OPEN_HTTP2', false), - 'task_worker_num' => envInt('SERVER_TASK_WORKER_NUM', 0), - 'task_enable_coroutine' => envBool('SERVER_TASK_ENABLE_COROUTINE', false), - 'open_tcp_nodelay' => envBool('SERVER_OPEN_TCP_NODELAY', true), - 'max_coroutine' => envInt('SERVER_MAX_COROUTINE', 1000000), - 'socket_buffer_size' => envInt('SERVER_SOCKET_BUFFER_SIZE', 2 * 1024 * 1024), -]; - -if (!empty($pidFile = env('SERVER_PID_FILE'))) { - $serverConfig['pid_file'] = $pidFile; -} - -return $serverConfig; diff --git a/frameworks/PHP/sw-fw-less/start.php b/frameworks/PHP/sw-fw-less/start.php deleted file mode 100644 index b5b58592280..00000000000 --- a/frameworks/PHP/sw-fw-less/start.php +++ /dev/null @@ -1,12 +0,0 @@ -run(); diff --git a/frameworks/PHP/sw-fw-less/sw-fw-less.dockerfile b/frameworks/PHP/sw-fw-less/sw-fw-less.dockerfile deleted file mode 100644 index 6cd83a9597f..00000000000 --- a/frameworks/PHP/sw-fw-less/sw-fw-less.dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM php:7.4 - -RUN pecl install swoole > /dev/null && \ - docker-php-ext-enable swoole - -RUN docker-php-ext-install pdo_mysql > /dev/null - -RUN apt -yqq update > /dev/null && \ - apt -yqq install git unzip > /dev/null - -# Composer -RUN curl -sS https://getcomposer.org/installer | php \ - && mv composer.phar /usr/local/bin/composer \ - && composer self-update --clean-backups - -# Bcmath extension required by amqp composer package -RUN docker-php-ext-install bcmath > /dev/null - -# Sockets extension -RUN docker-php-ext-install sockets > /dev/null - -ADD . /var/www/sw-fw-less - -WORKDIR /var/www/sw-fw-less - -RUN composer install --no-dev --quiet > /dev/null \ - && composer dump-autoload -o - -EXPOSE 9501 - -ENTRYPOINT ["php", "/var/www/sw-fw-less/start.php"] - -LABEL luoxiaojun1992 \ No newline at end of file