The subject assumes that, unlike other scripting languages such as nodejs, python, and ruby, PHP must rely on servers. Why does it not put the entire http lifecycle in php for management, does it have to rely on a web server to provide interfaces? The subject assumes that, unlike other scripting languages such as nodejs, python, and ruby, PHP must rely on servers. Why does it not put the entire http lifecycle in php for management, does it have to rely on a web server to provide interfaces?
Reply content:
The subject assumes that, unlike other scripting languages such as nodejs, python, and ruby, PHP must rely on servers. Why does it not put the entire http lifecycle in php for management, does it have to rely on a web server to provide interfaces?
For example, the workerman framework comes with a WebServer, which is managed by PHP throughout the http lifecycle and does not rely on nginx apache PHP-fpm, in addition, database linked resources and global objects can be permanently stored and reused, which improves the performance.
In addition, PHP also comes with a web server, which is started by php-S, but cannot be used in the production environment.
You can run the php file. php script directly on the command line without relying on the web server.
It's just that the architecture like nginx + PHP-fpm or apache + php for php web development is mature, so everyone has been using it like this and feels that PHP must rely on Web servers. Of course, if you want to use PHP to develop non-http applications, such as TCP persistent links, you have to use the PHP socket server framework instead of the existing web architecture.
PHP can run independently without relying on containers such as php-fpm, apache, and nginx.
Traditional PHP development is based on Web, basically HTTP, And the parsing and processing of HTTP are handled by WebServer alone, so developers do not care about protocol issues. However, when we need to develop based on non-HTTP protocol, the traditional WebServer cannot meet our needs. In this case, developers need to implement Protocol parsing.
The PHP interpreter now has a built-in server that can be started with php-S, although it can only be used for development and testing at present ..
No dependency. There is a command linephp a.php
You can execute a PHP file.
In Web servers, there is no essential difference between scripting languages such as php and python.
All are called and returned through the gateway interface
1. Because the current technology is mature, there is no need to develop a server.
2. the php language does not provide APIs to create a web server. The php language focuses more on web content processing. After an http request is completed, the current php engine recycles all the variable information. In other words, php is not resident in memory during web development.
This is not your proposition.
In the past, the php clisapi tool felt that it should be too important, so many people do not know or even know it. Therefore, they thought that php Code cannot be run without leaving the browser using the browser, however, many changes have occurred so frequently since php5.3, and php has been well integrated with apache since the very beginning, which makes it easy to handle http handover and conversion, enables users to process requests on the php layer, and response can easily process requests, unlike python and other languages, to develop web, You need to develop web frameworks by yourself to implement interfaces for data exchange with http. php frameworks are application frameworks. Without mod_php php-fcgi php-fpm, if you want to use php to develop a web framework, just like python and other languages, you can use php to develop a web framework that can hand over data with http. It is very convenient and simple to develop and deploy the web on the theme of php from the very beginning. There are few technical knowledge that has been implemented in the background, so php makes people feel so simple and easy to learn that so many people will use it. So some people will ignore whether php is not capable of breaking away from the web server.
There is a certain reason why PHP is so popular: it can be supported in various environments. If it has http, it is bound to limit its development.
Php running does not mean that containers must be relied on. Because nginx/apache + php is very mature and has sufficient performance, web developers will use these containers directly, which is stable and reliable, there are many documents.
Although PHP has ARC and GC, there is still Memory leakage.
PHP extension can be used to implement simple WEB Server. For example, this HTTP Server (http://php.net/manual/zh/eventhttp.construct.php) implemented with the HttpEvent extension ).
However, you can test that the Code officially provided by PHP has memory leakage. After tens of thousands of requests, the memory will be full.