">

Home  >  Article  >  Backend Development  >  php What is PEAR? Part 2

php What is PEAR? Part 2

WBOY
WBOYOriginal
2016-07-29 08:39:321092browse

▓ Package Introduction
The most important thing about PEAR is that it has many program libraries that developers can use for free. These libraries will be packaged into packages, and each package will contain a file named package.xml. This is a requirement of the PEAR team. This file records the file structure, version number and other information of the library. With this file, the library can be called a "package" only after it is compressed. Because of this xml file, PEAR The provided "package management commands" make it easy to manage the program library. For example, you can use commands to install packages, delete packages, view package information or upgrade packages, etc.
Also. Regarding the security of the package, if users find problems with the package, they can discuss it through the forum or report it to the development team, who will quickly make corrections and revisions. Therefore, each package will have a version number to distinguish the revisions. process.
Please refer to "Appendix A. PEAR official website introduction" for details. You will be rewarded.
Note, if you follow the example in this article and find that the results are different from what we introduced, please don’t be surprised. That’s because the PEAR suite is updated too fast. What we introduced The method and original intention will not change, but the process will change as the suite changes.
▓ How to get relevant information about the kit
If you want to download the kit or learn about the kit, readers can enter the PEAR official website (the URL is http://pear.php.net)
The circled hyperlink is where the kit is placed
No. 1 The thicker black words in the circle represent the category of the package. For example: Category 1 is called Authentication. This category currently contains 8 packages, which are used to handle login and logout or identity authentication and permission settings.
The smaller characters in the circle number 2 represent the name of the package, such as: Auth, Auth HTTP, etc. You can click on each package name to view more detailed package information or download the package.
So far, PEAR has 35 categories of kits, more than 300 kits, and a total of 202 members developing kits. However, these numbers are continuing to increase. If one day in the future, you would also like to be a part of the PEAR community. Members can contribute their own efforts or apply to become a developer of the suite.
To use the PEAR library, you need to follow the following basic steps:
1. Set up a web server, such as Apache, and install PHP and MySOL.
2. Some basic packages of PEAR must be installed. The so-called "basic package" is the package required by all PEAR packages. For example, debugging is required by every package, so the basic package includes the debugging package. You can only install the debugging package first. Only by installing the wrong package can other packages be debugged smoothly.
3. Install specific packages based on developer needs. For example, after installing the basic package. If a developer wants to add the function of calculating execution time to a web page, he must use the command to install the Benchmark package. This package is not a basic package and must be installed by the developer himself.
4. Reference the package's library file in the PHP program.
Below we will introduce how to install and manage the PEAR package under Windows operating systems and Unix-like operating systems.
3-2 Installation and management of PEAR on Windows series operating systems
▓ Install Apache+PHP+MySQL
If you have not set up a PHP execution environment, it is recommended that you install AppServ, a six-in-one software. The author uses AppServ to As a windows server environment. This software can be downloaded from the official website http://www.appservnetwork.com/.
▓ How to install PEAR
After installing AppServ, you can start to install the basic package of PEAR on Windows. The installation process can be divided into four steps.
Step 1: Enter the website http;//go-pear.org/
Please connect to the website http;//go-pear.org/ first
Then, after completely copying the text in the webpage, open the system Notepad in the accessory application, paste the text you just copied. After pasting, save the file in C:AppServ\www, which is the location of the root directory of the website. When saving, please be careful and select All as the save type. For the file, the subname needs to be php. Please name the file by yourself. Suppose I customize the file name as pear.php, as shown below:
If you don’t want to bother, you can also use web page editing software such as Dreamweaver to open a blank page. PHP file, then paste the copied text from http://go-pear.org and save it.
Step 2: Install the basic package
Open the browser and enter "http;//127.0.0.1 copy go-pear website file.php" or "http;//localhost/copy go-pear website file" in the URL bar. php", the so-called "copy go-pear website file.php" is the name of the file that I just copied and saved the copied text. In this example, it is pear.php, so I enter "http;//127.0.0.1/pear.php" , the web page for online installation of PEAR will appear. The first screen is the welcome screen, I won’t introduce it in detail. Please click NEXT >> to proceed to the next installation step. This page is used to set the installation location of the PEAR package. There is an HTTP proxy field at the top. If the installer needs to use a proxy to connect to the Internet, Please fill in the IP and port number of the proxy here. If you do not use a proxy, this field can be left blank.Then there are 10 installation path settings. Please pay special attention to them. Three of them must be modified, which are:
1. For the Install prefix in item l, please change the default c:AppServ﹨www to c:AppServ﹨php, because it is the PEAR library I want to be installed. Do not put it in www and mix it with the web pages in the root directory. .
2. For the Filename of WebFrontend in item 9, please change the default value to c:AppServ﹨www﹨pear﹨index.php. This means that a folder named pear is generated in www. The index.php in the folder is the package management interface generated by the system. This interface will be mentioned later (in case the subsequent operation fails, please first create a folder in C:AppServ﹨ Create a folder named pear in www).
3. The php.exe path in item 10 needs to be changed to c:AppServ﹨php﹨php.exe, which means the correct location of the php.exe file needs to be specified.
Just use the default values ​​for the rest of the settings. Here I will briefly introduce the meaning of the other settings:
● The second item of Binaries Directory is to specify the first item of c:AppServ﹨php as PEAR The root directory is represented by the variable $prefix.
● The PHP code Directory in item 3 is the location where the files are placed after the PEAR package is installed. The downloaded file of this sample PEAR package will be installed in c:AppServ﹨php﹨PEAR.
● Item 4 is if the installed package has built-in documentation, this example will be placed in c:AppServ﹨php﹨PEAR﹨docs.
● Item 5: If the installed package has a built-in sample file, this sample will be placed in c:AppServ﹨php﹨PEAR﹨data.
● Item 6 is if the installed package has a built-in test file. This example will be placed in c:AppServ﹨php﹨PEAR﹨test.
● Item 7 is where the PEAR cache file is placed. This example will be placed in c:AppServ﹨php﹨PEAR﹨cache.
● The 8th item is the lifespan of the cache file. In this example, the lifespan of the cache file is 300 seconds, which means it will be cached again after 300 seconds.
In addition, one thing to note is that the viewer of the web page must have write permissions to these paths, otherwise the installation will not be possible.
After modifying the setting items, press the smallest install button to install.
When the installation progress at the top reaches 100%, congratulations, you have completed the installation of the basic package. According to my test in an environment where the ADSL download speed is 2M, the installation is completed in about 2 minutes. If your network connection speed is not fast enough, or the connection is interrupted halfway through the installation, please click the refresh button at the top of the browser or Press F5 to reinstall.
After installation is complete. Please don't be too happy. PEAR has more than 300 packages. So far, only the basic package of PEAR has been installed. Not all packages have been installed. Other packages other than the basic package will be installed one by one when developers need to use them.
You may ask: "How to install other packages? Will it be troublesome?" Please rest assured that this is not troublesome. The installation and management of the packages will be introduced in detail in the next small unit.
After installing the basic package, enter c:Appserv﹨php and you will find a folder named PEAR. This folder is the path where the program library is placed after the package is downloaded and decompressed
For everyone By the way, the two folders docs and tests will contain good things for learning PEAR. Some packages will come with tutorial files. If the user installs the package, the tutorial files will be placed in the docs folder. Some packages come with sample programs. After the user installs the package, the sample program will appear in the tests folder
▓ Management of PEAR packages
After installing the basic package, when developers need to use other packages other than the basic package , you will need to install the package. If you do not need a certain package, you will want to remove the package. If the package version is too old, you will need to upgrade the package. This means that developers need a PEAR package management system.
There are two ways to install and manage packages under the Windows operating system. One is to use the Web management interface, and the other is to use the "package command". The author prefers the latter because the execution speed is faster, but if you are afraid of instructions, you can also use the first method to easily manage the package.

The above introduces php. What is PEAR? The second article includes relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

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