Home  >  Article  >  Backend Development  >  Development principles of 10 top PHP masters, 10 top PHP masters_PHP tutorial

Development principles of 10 top PHP masters, 10 top PHP masters_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:15:49797browse

Development principles of 10 top PHP masters, 10 top PHP masters

In the world of web development, PHP is one of the most popular languages. From PHP, you can It's easy to find the script you need. Unfortunately, few people use "best practices" to write a PHP program. Here, we introduce to you 10 best practices of PHP. Of course, each of them is proven by masters.

1. Use PHP when appropriate – Rasmus Lerdorf

No one understands where PHP is more reasonable than the creator of PHP, Rasmus Lerdorf. He released the PHP language in 1995. Since then, PHP has been like a prairie fire, burning all over the world. The development camp has changed the world of the Internet. However, Rasmus did not create PHP for this reason. PHP was born to solve practical problems of web developers.

Like many open source projects, PHP has become popular. The motivation for its popularity cannot be explained by normal philosophy, and it is even so popular that it is somewhat self-admiring. It can be used as a case, a case caused by the need for tools to solve various Web problems. Therefore, when PHP first appeared, all such tool needs were focused on PHP.

However, you cannot expect PHP to solve all problems. Lerdorf is the first to admit that PHP is just a tool, and there are many situations where PHP is beyond its capabilities.

Choose the right tool according to the job. I have gone to many companies to convince them to deploy and use PHP, but this does not mean that PHP is suitable for every problem. It is just a front-end scripting language that can solve most problems.

As a web developer, trying to solve every problem with PHP is unscientific and will waste your time. When PHP doesn't work, don't hesitate to try other languages.

2. Use multi-table storage to improve scalability – Matt Mullenweg

No one wants to question Matt Mullenweg’s authority in PHP. He developed the most popular blog system on the planet (supported by a strong community): WordPress. After creating WordPress, Matt and his team launched The WordPress.com platform is a free blog site based on WordPress MU. Today, WordPress.com has approximately 4 million users, who contribute more than 140,000 posts every day. (To see more WordPress.com statistics, click here.)

If anyone knows how to make a website scale easily, it’s Matt Mullenweg. In 2006, Matt made forward-looking improvements to WordPress's data structure and explained why WordPress MU uses independent MYSQL tables for each blog instead of stuffing all blog data into one huge table.

We tested this approach, but found that scaling it out would be too expensive. If you use an overall data structure, you will face server hardware problems in the face of large traffic. Inside MU. Users are distributed into separate tables and can be easily organized. For example, WordPress.com stores user data in 4,096 databases. These databases can disperse large-scale data access and divert traffic and pressure.

The portability of data tables allows the code (blog) to run faster and makes the system more scalable. Relying on powerful caching strategies and flexible database utilization strategies, Matt showed people that the most popular Facebook and WordPress.com can run stably under PHP and handle an astonishing amount of traffic.

3. Never trust users – Dave Child

Dave Child is the central figure at Added Bytes (previously ilovejackdaniels.com), a site famous for his excellent "cheat sheets for many programming languages". Dave works for a number of UK companies and has established himself as an authority in the programming world.

Dave provided a lot of thoughtful advice for PHP developers, and summarized it in "writing secure code in PHP": Never trust your users, they may even hurt you.

There is a basic principle of web development that I cannot repeat enough times: Never trust your users, and assume that every unit of data on your website is maliciously collected from users. code. Many times, you have to use JavaScript to verify the content submitted by the form on the client. If you are used to this, then this is a good habit. If security is important to you, this is the most important principle to learn.

Dave is currently working on organizing examples for his "Writing Secure PHP" series of books. At the end of the book, he said:

Finally, become a little paranoid. Unless you think your site will never be attacked, face the problem head on because when it does happen, you're going to be in a bad situation. You need to regard every user as a hacker who will bring about an attack and defense on the site, do everything possible to protect the security of the site, and at the same time think of solutions to the corresponding problems.

4. Use PHP caching more – Ben Balbo

Ben Balbo developed Site Point, a website that provides guidance to developers and designers. He is a member of the Melbourne PHP Development and Open Source Club, so he has a certain understanding of PHP and has certain ideas and experience in PHP caching.

If you have a site that has a lot of visits but is not updated frequently (such as a blog, based on some kind of CMS), maybe it needs some modifications. These modifications will not take too much time, but will have a negative impact on performance. Outstanding contribution. If you want to establish a caching mechanism for a complex/fast-updating site, the process may be tortuous, but the benefits are obvious.

There are many PHP caching technologies. Ben recommended the following ones for us:

 ◆Cache function execution results

 ◆Set expiration time

 ◆Caching files downloaded by IE

 ◆Template caching technology

 ◆Cache_Lite

Due to the characteristics of PHP as a dynamic language, the caching mechanism is very important for sites that are not updated frequently.

5. Accelerate PHP development with IDE, Templates and Snippets – Chad Kieffer

When Chad Kieffer takes a break from UI design and database optimization, he shares a lot of technical experience on his blog 2 tablespoons. Due to Chad's comprehensive development in many aspects, he can often find problems that other programmers cannot find and form relevant experience, especially his method of developing websites. He is involved in every aspect of website development, so his advice is very useful in improving the big picture of website development.

Chad believes that using an IDE like Eclipse PDT (Eclipse’s PHP development package) and using some template technologies and open source projects can effectively increase the development speed of PHP.

Compact plans, long to do lists and deadlines make developers very frustrated. However, some features, such as Eclipse Templates, can effectively reduce coding time and the chance of errors.

Generally speaking, any project can be automated. The higher the degree of automation, the shorter the time it takes to complete the project. Taking the time to develop frameworks and templates that will be used frequently will save you even more time later. At the same time, using an IDE like Eclipse and the PDT package, you will find that your efficiency is significantly improved. The IDE can automatically close, complete semicolons and debug locally.

6. Make good use of PHP filter functions – Joey Sochacki

Maybe Joey Sochacki is not as famous as Matt Mullenweg, but he is also an experienced developer and has shared a lot of technical experience through his blog Devolio.

Joey found that there are many places that need to be filtered when writing PHP code, but not many coders pay attention to PHP's built-in filtering function.

Filtering data is something we often need to do, but many feature-rich PHP built-in filtering functions are unknown. Using PHP built-in functions like filter_*, we can handle almost all filtering tasks, including data type validation/URL/email and IP address validation/special character processing, etc.

Filtering is a complicated thing, but I believe joey's discovery will give you a lot of inspiration and let you realize the powerful filtering function of PHP.

7. Use PHP framework – Josh Sharp

There has been a lot of controversy over whether you should use Zend, CakePHP, Code Igniter, or other PHP frameworks, but in the minds of web developers, they have their own standards of measurement.

Josh Sharp has created a website that provides bread and butter services, so he has some experience in using PHP framework to develop websites. He believes that using a PHP framework for project development can effectively save time and reduce the chance of errors. Why? Because he feels that PHP is really easy to get started with.

The ease of use of PHP is sometimes flawed, because the loose syntax often leads to the creation of many erroneous codes. But if you use a PHP framework, the chance of errors will be greatly reduced.

PHP framework can make your code structure more standardized and save a lot of time.

8. Don’t use PHP frameworks – Rasmus Lerdorf

Contrary to Josh’s view, Rasmus Lerdorf, the originator of PHP, believes that it is best not to use the PHP framework. Why? Because PHP that is not based on a framework performs better. In his speech at Drupalcon 2008, Rasmus used the "Hello World" example to compare the performance between some framework PHP and simple PHP. The results showed that the performance of framework PHP was far behind.

9. Using batch processing – Jack D. Herrington

Jack Herrington is no stranger to the PHP world, and has contributed more than 30 articles to the famous IBM developerWorks, and also published the book "PHP Hacks", so he is a true expert.

Herrington recommends using batch processing and Cron to replace program scripts that can run in the background. Web users are not willing to wait for your processing online, so some things are better suited to be processed in the background.

Admittedly, this is overkill in some cases, but you can clearly see that using Cron, MySQL, PHP object-oriented methods, and Pear::DB are convenient tools to create a batch processing tool and Not a complicated thing.

Jack believes that using cron, PHP and MySQL to process some tasks in the background is much more cost-effective than multi-process business logic.

I have tried both methods. I think Cron is very consistent with the "Keep It Simple, Stupid" (KISS) principle. It makes background processing simple. Compared with multi-process business logic, it has no risk of memory overflow. You can create a simple batch script and run it in cron. This script will regularly check whether there are tasks that need to be processed, and will automatically exit after processing, so you don't have to worry about whether a process is stuck or stuck in an infinite loop.

10. Enable error reporting in a timely manner – David Cummings

David Cummings has a company that specializes in providing CMS software services and has won several awards. He has very rich experience in PHP development. David once wrote "two PHP tips he wished he’d learned in the beginning", one of which is: enabling error reporting in time, which will save a lot of time.

I tell people that the most important thing is to maximize error reporting in PHP. Why? Because PHP may hide many small problems:

 ◆Variables are not predefined

 ◆An unavailable variable is referenced in the code snippet

 ◆Using undefined constants These factors may not seem like a big deal unless you are writing some class library using an object-oriented approach. Often, turning off error reporting will likely cost you more to maintain your code.

Error reports can help you easily find problems with your code. If the level of the error report is high enough, subtle errors can be discovered immediately, helping you save overall debugging time.

Top PHP development framework

In foreign countries, there are special websites for evaluation and tracking

The following are the ten most popular PHP frameworks based on the MVC design pattern.
1. Yii

Yii is a component-based, high-performance PHP framework for developing large-scale Web applications. Yii is written in strict OOP and has complete library references and comprehensive tutorials. From MVC, DAO/ActiveRecord, widgets, caching, hierarchical RBAC, Web services, to principalization, I18N and L10N, Yii provides almost everything needed for today's Web 2.0 application development. And the price of this frame is not too high. In fact, Yii is one of the most efficient PHP frameworks.
2. CodeIgniter

CodeIgniter is an application development framework - a toolkit designed for people who build PHP websites. Its goal is to develop projects quickly: it provides a rich set of libraries to complete common tasks, as well as a simple interface and a well-organized structure to access these libraries. Developing with CodeIgniter can inject more creativity into your projects because it saves a lot of coding time.
3. CakePHP

CakePHP is a framework for rapid development of PHP, which uses some common design patterns such as ActiveRecord, Association Data Mapping, Front Controller and MVC. Its main goal is to provide a framework that enables PHP developers of any level to quickly develop web applications, and this rapid implementation does not sacrifice the flexibility of the project.
4. PHPDevShell

PHPDevShell is an open source (GNU/LGPL) rapid application development framework for developing pure PHP without Javascript. It has a complete GUI administrator backend interface. Its main goal is to develop management-based applications such as plug-ins, where speed, security, stability and flexibility are the top priorities. It's designed to have an easy learning curve, so PHP developers don't need to learn complex new terminology. The arrival of PHPDevShell meets developers' needs for a lightweight but fully functional GUI that can be configured without restrictions.
5. Akelos

Akelos PHP framework is a web application development platform based on the MVC design pattern. Based on good usage habits, you can use it to complete the following tasks:
◆Conveniently use Ajax to write views
◆Manage requests and responses through controllers
◆Manage international applications
◆Use simple protocols to communicate with models and databases
Your Akelos application can run on most shared hosting providers because the only requirement for Akelos on the server is to support PHP. Therefore, the Akelos PHP framework is ideal for publishing stand-alone web applications because it does not require non-standard PHP configuration to run.
6. Symfony

Symfony is a web application framework for developing PHP5 projects.
The purpose of this framework is to speed up the development and maintenance of web applications and reduce repetitive coding work.
Symfony has low system requirements and can be easily installed on any setup: all you need is a Unix or Windows server and a web server with PHP5 installed. It is compatible with almost all databases. The price of Symfony is not high, much lower than the cost of a host.
For PHP developers, using Symfony is a natural thing, and the learning curve is only one day. Clean design and code readability will shorten development time. Developers can apply the principles of agile development (such as DRY, KISS or XP, etc.) and focus on the application logic level without spending a lot of time writing endless XML configuration files.
Symfony is designed to build complete enterprise-level applications. That is, you have control over the entire setup: from path structure to external libraries, almost everything can be customized. In order to comply with enterprise development regulations, Symfony also bundles some additional tools to facilitate project testing, debugging, and archiving.
7...The rest of the text>>

Who are the top potential development masters in the world?

It is recommended to read the world’s best-selling book and the best-selling spiritual inspirational book in history ~ "The Secret" and the video by Rhonda Byrne, which introduces the rules of ultimate potential development (that is, the complete development of the right brain and subconscious mind). I believe it will be useful to you. Help~

There are two movies. You can search "Secret Law of Attraction" and "Secret 2 the opus" on Youku

You can also watch it on the "Secret" Chinese website (Quantum " Secret Forum) hi.baidu.com/...7.html Download the high-definition video

The masters in the video are all world-class potential masters and success masters~

Among them Anthony Luo Bin recommended: I dare say that anyone who truly understands "The Secret" will definitely be able to get everything he wants! ——Anthony Robin

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/902432.htmlTechArticleDevelopment principles of 10 top PHP masters, 10 top PHP masters In the world of Web development, PHP is the most popular One of the languages, from PHP, you can easily find the script you need, unfortunately...
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