Home  >  Article  >  Backend Development  >  Senior programmers tell you that today’s PHP is different

Senior programmers tell you that today’s PHP is different

韦小宝
韦小宝Original
2018-03-01 14:37:181639browse

PHP has a very high global market share, second only to Java. According to data from various recruitment websites, there are many positions for PHP development, and the salary level is also very good. In fact, the market position of PHP in small and medium-sized enterprises and Internet startups is higher than that of Java.

PHP has a history of more than 20 years since its birth. From the rise of the Web era to the ebb of the mobile Internet, various programming languages and technologies have emerged one after another in the Internet field, including Node.js, GO and Python. It is challenging PHP's status. The promoters of these technologies are very keen to badmouth PHP. What is the future of the PHP language? How should PHP programmers cope with future changes?

As a veteran Web back-end programming language, PHP has a very high global market share, second only to Java. According to data from various recruitment websites, there are many positions for PHP development, and the salary level is also very good. In fact, the market position of PHP in small and medium-sized enterprises and Internet startups is higher than that of Java. Java has greater advantages in very large enterprises, traditional software industries, and financial fields. At present, languages ​​such as Node.js, GO, Python, and Ruby are still difficult to match PHP and Java.

The reason why the PHP language has achieved today's status is due to the fact that PHP language designers have always followed pragmatism and hidden the technical complexity at the bottom. The PHP language is simple to get started with and easy to master. The program is robust and not prone to complex problems like Java, C++ and other languages, such as memory leaks and crashes. Tracking and debugging are relatively easy.

The standard library officially provided by PHP is very powerful. Various functional functions can be found in the official standard library, including MySQL, Memcache, Redis, GD graphics library, CURL, XML, JSON, etc., eliminating the need for Developers have the trouble of looking for libraries everywhere. PHP's documentation is excellent, with detailed descriptions and usage examples for each function. Third-party libraries, tools, codes, and projects are also abundant. Developers can use PHP to write and develop various software quickly and efficiently.

So far, there is still no programming language on the market that is simpler and easier to use than PHP. Therefore, the prospects of PHP are still very broad. Instead of worrying about the choice of programming language, it is better to learn and use PHP in depth.

As a senior PHP developer, I would like to give you some technical suggestions for the future of PHP programs. I hope it will be helpful to everyone.

1. Composer

The first point is to mention Composer. Since the emergence of Composer, PHP dependency management can become very simple. The program relies on some class libraries and frameworks, which can be introduced directly using Composer, and the dependent packages can be installed using composer update. Various difficulties in loading external libraries in the past have been solved.

Composer also has domestic mirrors, which are very fast. Most PHP open source projects now provide support for Composer. It is recommended that you use Composer to solve the PHP code package management problem in your project. Do not use the original method of downloading the source code and manually including it.

2. PHP7

The PHP7 version has made a lot of modifications to the Zend engine, which greatly improves the performance of the PHP language. Using PHP7 can instantly double the performance of your program. . Even heavyweight software like WordPress can achieve thousands of QPS when running on PHP7, which is equivalent to a server that can handle 80 million requests per day.

Use PHP7, optimize MySQL, and use Memcache and Redis for acceleration. This technical architecture can fully cope with quite large-scale systems. Except for some platforms with hundreds of millions of users, systems of average size are completely stress-free.

3. PSR

PSR is the PHP language development specification formulated by the PHPFramework Interop Group, which stipulates many rules, such asNamespace, class name specifications, coding style standards, Autoload, public interfaces, etc. It has now become the de facto standard in the PHP technology community. Many well-known PHP frameworks and class libraries comply with the PSR specification. PHP developers should learn to master the PSR specification and try to follow the PSR specification when developing programs.

4. Swoole

Is PHP still limited to web websites in 2017? No, if you don’t know Swoole yet, go find out about it quickly. Swoole's slogan is to redefine the PHP language. Swoole is an asynchronous and parallel communication engine that runs as an extension of PHP. There is an asynchronous callback Swoole in Node.js, and there is also a coroutine Swoole in the Go language, which completely subverts the understanding of PHP. Using Swoole PHP, you can implement a memory-resident server program and realize the programming development of TCP and UDP asynchronous network communication.

In the past, PHP could only build a Web website, but now Swoole can be used to provide communication services that can only be implemented in Java and C++, such as WebSocket communication, chat, push server, RPC remote calling service, gateway, proxy, and game server. wait. If you want to use PHP to do something other than web systems, Swoole is the best choice.

5. Laravel

The most popular PHP framework in recent years, the official website claims to be a framework designed for Web artists, which shows how elegant this framework is. Laravel provides rich functional modules, simple API design, and strong expressiveness. Moreover, its community is very active, there are many code contributors, there are many third-party plug-ins, and the ecosystem is quite prosperous.

Laravel uses a lot of symfony2 components at the bottom layer, and realizes dependency management through composer. If you are still wondering which PHP framework to use, it is better to choose Laravel. The command line tool provided by Laravel is based on symfony.console and is powerful. It integrates various project management and automatic code generation functions.

6. Phar

After PHP5.3, a Java-like jar package is supported, named phar. Used to package multiple PHP files into one file. This feature allows PHP to package and componentize applications as easily as Java. An application can be packaged into a Phar package and run directly in PHP-FPM.

With Swoole, you can execute php server.phar on the command line to start the server with one click. PHP code packages can be packaged into components using Phar and placed in Swoole's server container for loading and execution.


The above is the detailed content of Senior programmers tell you that today’s PHP is different. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn