Home > Backend Development > PHP Tutorial > php What is PEAR? (Part 2)_PHP Tutorial

php What is PEAR? (Part 2)_PHP Tutorial

WBOY
Release: 2016-07-21 15:47:53
Original
1013 people have browsed it

▓ Introduction to the package
The most important thing about PEAR is that it has many 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.
For details, please refer to "Appendix A. PEAR official website introduction". 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 quickly. The method and original intention of the introduction 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 placed Where the package is located
The thicker black words in the circle number 1 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 also want to contribute to the PEAR community To contribute as a member, you can also 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 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 http;//go-pear.org/ website
Please connect to the website http;//go-pear.org/ first
Then, complete the text in the webpage After copying, open Notepad in the system's accessory application and paste the text you just copied. After pasting, save the file in C:AppServ\www, which is the location of the website root directory. Please pay attention when saving. , please select all files as the archive type. The subname needs to be php. Please name the file by yourself. Suppose I customize the archive name as pear.php, as shown below:
If you don’t want to bother, you can also use Dreamweaver or the like. Use web editing software to open a blank PHP file, then paste the copied text from http://go-pear.org and archive 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.php", where 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 further. 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 Route, 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
is the PEAR library I want to be installed. Do not put it in the www and mix it with the web pages in the root directory. together.
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 you need to specify the correct location of the php.exe file.
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, Binaries Directory, is the c:AppServ﹨ of the first item. php is designated as the root directory of PEAR and 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. The lifespan of the cache file in this example 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, there are good things for learning PEAR in the docs and tests folders. 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 the developer needs to use other than the basic package When using other packages, 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. In other words, developers need a set of 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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319875.htmlTechArticle▓ Package Introduction The most important thing about PEAR is that it has many libraries for developers to reference for free. These libraries will Are packaged into kits, and each kit will contain a package called pack...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template