Share the development principles of 10 top PHP development Engineers

Source: Internet
Author: User
Tags php and

  I'm going to faint, who am I going to listen to? in the Web development World, PHP is one of the most popular languages, from PHP, you can easily find the script you need, unfortunately, very few people to use "best practices" to write a PHP program. Here, we introduce PHP's 10 best practices, and of course, each one is proven by the Masters.

1. Use Php–rasmus Lerdorf at the right time

No one is more reasonable than PHP's creator Rasmus Lerdorf understand where PHP is used, he released the language of PHP in 1995, and since then PHP has been like a prairie fire, burning the entire development camp and changing the world of the Internet. However, Rasmus does not create PHP for this reason. PHP was created to solve the real problem of web developers.

Like many open source projects, PHP became popular, and the motivation of popular motives was not explained by normal philosophy, or even a bit narcissistic. It can be a case in point, a case of a tool that solves a variety of web problems, so when PHP first appears, the tool needs all focus on PHP.

But you can't expect PHP to solve all the problems. Lerdorf is the first person to admit that PHP is just a tool, and PHP has a lot of power to do.

Choose the right tool depending on your job. I ran a lot of companies to convince them to deploy and use PHP, but that doesn't mean that PHP applies to all the problems. It can only be a front-end Footstep language that solves most of the problems.

As a web developer, trying to solve all the problems with PHP is unscientific and wastes your time. When PHP is not playing, do not hesitate to try other languages.

2. Using multiple table storage to improve scale scalability –matt Mullenweg

No one wants to question Matt Mullenweg's authority on PHP, who has developed the most popular blogging system on the planet (backed by a strong community force): WordPress. After creating WordPress, Matt and his team started the WordPress.com platform, a free blog site based on WordPress MU. Now, WordPress.com already has about 4 million users, who provide more than 140,000 logs a day. (To see more wordpress.com statistics, click here.)

If someone knows how to make a website scale, this person must be Matt Mullenweg. In 2006, Matt improved the data structure of WordPress and explained why WordPress MU uses a separate MySQL form for each blog instead of stuffing all the blog data into a huge table.

We tested this approach, but found it too expensive to extend its scalability. If you use a whole data structure, in front of large traffic, you will face the problem of server hardware. In Mu. Users are distributed to separate tables and can be easily organized. For example, WordPress.com stores the user's data in 4,096 databases, which can disperse large-scale data access to achieve flow and pressure streaming.

The mobility of datasheets allows code (blogs) to run faster and make the system more scalable. Relying on a powerful caching strategy and a flexible database strategy, Matt showed people that the most popular Facebook and wordpress.com can run stably under PHP and handle amazing traffic.

3. Never trust the user –dave child

Dave Child is at the heart of the added Bytes (previously ilovejackdaniels.com) website with his excellent cheat sheets for many programming and famous. Dave serves a lot of British companies and has established considerable authority in the world of programming.

Dave offers a lot of forethought advice to PHP developers and concludes with writing secure code in PHP: Never trust your users, they may even hurt you.

There is a basic principle of web development, I repeat how many times that is not enough, that is: do not trust your users, but also assume that every data unit in your site is the malicious code collected from the user. Most of the time, you have to use JavaScript in the client to check the form submitted over the content, if you are accustomed to this, then, this is a good habit. If security is important to you, this is the most important principle you need to learn most.

Dave is currently working on an example of its "writing Secure PHP" series of books, and at the end of the book he says:

Finally, be paranoid. Unless you think your site will never be attacked, face up to all the problems and your situation will get worse when the problem really happens. You need to treat each user as a hacker who will bring an attack and defense station, try every means to protect the safety of the site, at the same time think about the solution of the corresponding problem.

4. Multi-use PHP cache –ben Balbo

Ben Balbo has developed site Point, a website that provides guidance for 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 some ideas and experience for PHP caching.

If you have a site with a lot of traffic, but not very frequent updates (such as blogs, based on some kind of CMS), perhaps it needs some transformation, which will not take much time, but can make a significant contribution to performance. The process can be tortuous, but the benefits are obvious if you want to create a caching mechanism for a complex/frequently updated site.

There are many kinds of PHP caching techniques, and Ben recommends some of the following:

Run result of the cache function

Set Expiration Time

Cached IE downloaded files

Template Caching Technology

Cache_lite

Because of PHP's characteristics as a dynamic language, caching mechanism is very important for sites that are not updated frequently.

5. Use IDE, templates and snippets to accelerate PHP development –chad Kieffer

When Chad Kieffer from work on UI design and database optimization, he shares a lot of technical experience on his blog 2 tablespoons. Because of the all-round development of Chad, he can often find problems that other programmers can't find and develop relevant experience, especially the way he develops the website. He is involved in all aspects of the site development, so his advice is useful for improving the development of the site.

Chad that using the IDE such as Eclipse PDT (Eclipse's PHP development package) and using some template technology and open source projects can effectively improve PHP's development speed.

The compact plan, the long to do lists, and the deadlines make the developers very depressed. However, some features, such as Eclipse Templates, can effectively reduce coding time and error probability.

In general, any project can be automated, and the higher the level of automation, the less time you will have to complete the project. Taking the time to develop frameworks and templates that use a high frequency will save you more time. At the same time, using an IDE like Eclipse and the PDT package, you will see a significant improvement in efficiency, the IDE can automatically close, complete the semicolon, and can debug locally.




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.