Accelerate PHP program development with PEAR

xiaoxiao2021-03-06  39

Source: techrepublic

Timely delivery applications are the key to determining what technology adoption, PHP will greatly promote its development process by means of PEAR (PHP Extension and Application Repository: PHP extension and application library). PEAR is a code base that provides a pre-written class for standard program features, which greatly reduces the development time of the application. PEAR is conceptual with Perl's CPAN, PEAR contains a functional function with rich features, including databases, messages, and error handling. In the case of PEAR, developers can deploy and enhance the basic functions of the prepared, and focus on the aspect of the writing program.

PEAR foundation

The purpose of creating PEAR is to provide a standardized way for developers sharing PHP code and promoting code reuse. The project is always in the process of development, users can submit their own code to join the PEAR library, the latter is bundled with PHP. All PEAR packages are strictly complied with coding rules in consideration of grammar and readability, which consists of PHP or PHP extensions written in C language. Stig Bakken started to develop PEAR projects later in 1999. His purpose is to create an organized code base that plays a repository of the PHP developer community by this code base. The project has grown very quickly in the past two years, and it has already included considerable, very useful scalable code. Although there are many other PHP code libraries, such as Zend's Code Gallery and PHP Builder's Source Code Snippet Library, the PEAR provides a standard for interoperability between a convenient function. In addition, the code submitted to PEAR accepts strict inspections, which guarantee the quality and reliability of the code from this type of standard and inspection.

Useful website

PEAR website PHP.NET Concurrent Version System Zend

Available features

PEAR is divided into three categories: PEAR core components, PEAR packages and PECL packages. The core component includes the base class of PEAR and PEAR_ERROR and database, HTTP, logging, and email functions. The PEAR package includes functions that provide authentication, networked and file system characteristics, and tools using XML and HTML templates. The PECL package is an extension of PHP, which is written in C language and does not comply with the coding rules. Currently, all this category is experimentally. For more information on PEAR features, please refer to the PEAR online manual. If you are interested in submitting the code, you can join the PEAR developer mailing list and ask you to check your code to achieve the above purpose. However, you have to note that functions already included in the library and comply with PEAR coding rules.

Where to get PEAR

Pear bundles in the PHP release package, and install PEAR at the same time when you install PHP. If you plan to get a stable version, and you can live without the latest PEAR version, then you can get the latest PHP version from the PHP.NET download page. If you love to adventure, I hope to use the latest version of PEAR, you can download it with the CVS client according to the instructions visited by anonymous CVS. The PEAR resource will be placed in ~ / php / pear / directory after installing PHP. You may wish to add your PHP directory location to the php.ini's incrude_path parameter (such as include_path = ".: / Usr / local / lib / php", so you can use PEAR functionality.

How to use PEAR

Now what you have to do is made by request_once () in other classes you have written. The example in List A uses PEAR email feature Sendmail. This part of the code exemplifies the mail.php file in the PEAR library, which is an extension to the Pear.php class. Next, we set some necessary variables, which are $ Recipients, $ Headers and $ Body, which are required for all PEAR Mail functions and $ params. You can participate in the line PEAR manual to find out how the variable is set. There is also a lot of information in the annotation of the PEAR code itself, but in general, the website is the biggest for you. Finally, the sample code will call the Pear Mail class. First, we use the Mail :: Factory method in the ~ / php / mail.php file to include the appropriate class file for the mail driver. In our example, it is Sendmail (in ~ / php / mail / sendmail.php file) Inside). Then, we actually call the mail sending function from the Pear Mail class. When we use references (= &) to instantiate the Mail class, you can reference this class by reference name $ mail_Object. If you want to know the usage of the Pear DB function, you may wish to go to the Quick Start Guide to Pear DB, which is maintained by Tomas V. V. Cox. Why use PEAR?

As mentioned above, the PEAR function is deployed simple, and there is no additional programming. Although we can reach the same result with the inherent function of PHP, the deployment PEAR module can immediately bring the actual interests such as error checking, and also facilitate the reuse of the program. In addition, more and more advanced applications have also begun to use PEAR, while PEAR's code library is also growing. Because PEAR is included within PHP permissions, you can use or modify the function you selected. Also, you don't have to repeatedly write a numb certification module, which is a considerable advantage of developers, and you can also enjoy the great advantages of custom development.

Benefits

With qualified preparatory, you can use the code, you can significantly speed up the development cycle of the application without having to overcome the brain. PEAR is a result that the PHP community pays out for the convenience of developers, which provides a complete set of methods for achieving excellent applications. PEAR code and make your own contributions not only speed up project delivery time, but also develop quality and better applications today and in the future.

TechRepublic is an online community and resource center designed for various IT professionals. We offer a deep technical article, which is written by IT experts, facing IT expert readers. In addition to providing various articles such as Windows to E-mail to firewall, we also provide IT industry analysis, download, management points, discussion groups, and newsmail services.

转载请注明原文地址:https://www.9cbs.com/read-77610.html

New Post(0)