-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ngx-php is orders of magnitude faster than php-fpm #1
Comments
Hi @joanhey 👋 ngx-php is a good project, and writing some articles about it may be of value to most people, but for now, it may be a bit late. Its threshold for getting started depends on the perfection of the ecosystem, including migration tools, debug/trace tools, pre-built images, etc. I think this is more feasible if the project author gets involved. Maybe you can try to ask the project author, is there a plan for this? Looking forward to hearing your suggestions. Regards |
It's an open source project, and It's up to everyone to help. Now I'm creating a class, to use almost any modern php app without any change (without migrations). The debug/trace tools work the same than with normal php. Pre-built images are good for testing, but not for production. And we need to show realistic benchmarks, and show ways to better code in async php. |
The ecosystem is OK. But the solutions need to go in the right direction. All async PHP solutions (ngx-php, workerman, amp, react, ...) are persistent apps. The problem with the classes, that are already defined and can't be redeclared, it's the same that happen with nodejs, ... Separate the classes, like you had at the beginning of your article (template and whisper), and in the The problem is NOT with global or static variables. It's with redeclaring constants and classes. There are better solutions, that we will show later, but this is very simple. |
In reality you can do the same with the constants and creation of the dir. config.php <?php
date_default_timezone_set('Asia/shanghai');
define('TEMPLATE_DIR', '/usr/share/nginx/html/templates');
define('DATA_DIR', '/usr/share/nginx/html/data');
define('WHISPER_PER_PAGE', 5);
define('ERROR_IS_EMPTY', '内容不能为空');
if (defined('DATA_DIR')) {
if (!file_exists(DATA_DIR)) {
mkdir(DATA_DIR);
}
} else {
echo "需要定义数据目录";
exit;
} Now the <?php
include_once('config.php');
include_once('template.php');
include_once('whisper.php');
new Whisper(); Also change the This solution will work with ngx-php and php-fpm or apache mod_php. And fixed the 2 problems. |
All modern PHP frameworks and apps, use a front controller normally in the So you will not need to include the files, and will be ready for ngx-php. example: <?php
require_once __DIR__."/vendor/autoload.php";
$app = new Slim\App();
$app->run(); |
Hi Su Yang
I really like ngx-php, and I added OPCache to it with the help of the author.
Also I maintain almost all php frameworks in the Techempower benchmark.
But hat numbers don't look correct to me. And ngx-php need more marketing.
I will try to send issues and PRs to explain the correct use of ngx-php.
As you seem to be a good communicator, could you explain it in Chinese.
I will try the same in English and Spanish.
Regards
The text was updated successfully, but these errors were encountered: