Why does PHP have to rely on Web servers?

Source: Internet
Author: User
Tags apache php php framework php web development
The main problem is: Unlike other scripting languages such as Nodejs, Python, Ruby, PHP must rely on the server exists, why it does not put the entire HTTP life cycle into the internal PHP to manage, rather than rely on a Web server to provide interface?

Reply content:

The main problem is: Unlike other scripting languages such as Nodejs, Python, Ruby, PHP must rely on the server exists, why it does not put the entire HTTP life cycle into the internal PHP to manage, rather than rely on a Web server to provide interface?

Pure PHP Implementation of Webserver also have Ah, for example, the Workerman framework comes with a webserver, the entire HTTP life cycle is managed by PHP itself, not dependent on Nginx Apache PHP-FPM, and the database link resources, Global objects can be permanently saved and reused, and the performance is really improved.

In addition, PHP also comes with a Web server, php-s boot, but not for production environments.

The command line can also run the PHP file.php run script directly, and do not rely on the Web server.

Just like PHP web development nginx+php-fpm or apache+php such architecture is more mature, so everyone has been so used, it feels like PHP must rely on Web server. Of course, if you want to use PHP to develop non-HTTP protocol applications, such as TCP long links, but also really out of the existing Web schema, you have to use the PHP Socket server framework.

PHP can run independently without relying on PHP-FPM, Apache, Nginx, and other containers.

Traditional PHP Development is web-based, basically HTTP protocol, HTTP protocol parsing processing by webserver alone, so developers do not care about the protocol. However, when we need to develop based on non-HTTP protocols, traditional webserver cannot meet our needs, and developers are required to implement the Protocol parsing section.

PHP interpreter now has a built-in server that can be started with php-s, although it is currently only available for development testing.

No dependency yes, there is a command line php a.php to execute a PHP file
In the Web server, scripting languages like PHP and Python are not fundamentally different.
are called and returned through the Gateway interface.

1. Since the current technology is ripe, there is no need to develop a server.
The 2.php language does not provide an API to create a Web server,php language that is more focused on Web content processing. The current PHP engine after the end of an HTTP request, all the variable information is collected, the development of the web process of PHP is not resident memory.

You're wrong about this proposition.

The previous PHP Clisapi This tool feel should be too much attention, so that many people are not clear or even know, so that running PHP code must use the browser to leave the browser PHP can not run, But now from the php5.3 began to update so often a lot of changes, and then there is PHP from the beginning with Apache has a very good combination very good very convenient to deal with the HTTP handover, so that people can be in the PHP itself at the level of processing request,response can be too convenient to handle, Unlike Python and other languages to develop the web itself to implement the interface with the HTTP Exchange data to implement the development of the web itself to develop some web framework, PHP framework is the application framework. If there is no mod_php php-fcgi php-fpm These things, then want to use PHP to develop the web as Python and other languages, using PHP to develop the implementation of the HTTP interface with the data to the web framework. For the first to learn PHP is a straight-dumb topic development, deployment of the Web is very convenient and simple, there is little mention of the technical knowledge behind the implementation, so PHP will make people feel so easy to learn to have so many people use it. That's why some people ignore the ability of PHP to get away from the Web server and run it alone.

PHP so fire, there is a certain reason: he can be supported in a variety of environments, if you have HTTP, it is bound to limit his development.

PHP Run is not to say that must rely on the container, because nginx/apache+php is already very mature, the performance is enough, the web development people are directly using these containers, stable and reliable, many documents.

Although PHP has arc and GC, there is still a memory leak.
A simple web Server can be implemented with PHP extensions. For example, the HTTP Server (http://php.net/manual/zh/eventhttp.construct.php) implemented with the httpevent extension.

But you can test it, PHP is officially provided by the code is a memory leak, after a hundred thousand of requests after the memory ran full

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.