1. What is pear?
Pear is the abbreviation of PHP extension and application repository (PhP extension and application library. Pear provides PHP users with a set of basic class libraries. When writing a PHP program, you can call the relevant pear classes to simplify our workload. For example, in a program, I want to extract the data in the database through the condition settings on the web page and transfer the data to an Excel table. To complete this task, it was not very easy to do in the past. Fortunately, now with pear, by calling the spreadsheet class in pear, we can write to excel in a short time. To put it bluntly, let's start our pear installation journey as soon as possible.Ii. Install PearFirst, introduce my system environment:
Windows 2000
Wamp1.4.3 (APACHE 1.3.33 + PhP 5.0.3 + MySQL 4.1.8) You may be unfamiliar with Wamp, in Windows, it takes some effort to install and configure the three software. Wamp (Windows Apache MySQL PHP) can help us do not need to configure any, as long as it's official website http://www.wampserver.com/en/download.php download a file about 20 mname for wamp5_1.4.3.exe, then you can immediately create a set of environments including Apache, MySQL, and PHP/by running the installation directly. This is really simple.
Well, after the system is configured, let's install pear next. Since PHP 4.04, pear has been distributed along with the PHP core. Go to the PHP installation directory, double-click the go-pear.bat, a command prompt window will pop up, displays the following information:
Welcome to go-pear! Go-pear will install the 'pear 'command and all the files needed byit. this command is your tool for pear installation and maintenance. go-pear also lets you download and install the pear packages bundledwith PHP: DB, net_socket, net_smtp, mail, xml_parser, phpunit. if you wish to abort, press control-C now, or press enter to continue: the system will download and install dB, net_socket, net_smtp, mail, xml_parser, and phpu. Pear, including nit, are several basic class libraries.
Press enter to perform the next step.Press enter to display the following information:
HTTP proxy (http: // User: password@proxy.myhost.com: port), or enter for none: Set the HTTP proxy server, if your IP address is a public IP address, you do not need to set,Press enter.Press enter to display the following information:
Below is a suggested file layout for your new pear installation. tochange individual locations, type the number in front of thedirectory. type 'all' to change all of them or simply press ENTER toaccept these locations. 1. installation Prefix: D:/software/Wamp/Php 2. binaries Directory: $ prefix 3. PHP code directory ($ php_dir): $ prefix/pear 4. documentation base Directory: $ php_dir/docs 5. data base Directory: $ php_dir/data 6. tests base Directory: $ php_dir/tests 7. php.exe path: D:/software/Wamp/PHP/php.exe 1-7, 'all' or enter to continue:
Set the system environment related to PhP. If you install PHP using Wamp
Press enter here.Press enter to display the following information: The following pear packages are bundled with PHP: DB, net_socket, net_smtp, mail, xml_parser, phpunit. wocould you like to install these as well? [Y/n]: Indicates whether to download and install dB, net_socket, net_smtp, mail, xml_parser, and phpunit class libraries. Of course, yes,
Input
Y
Then press Enter.Press enter to display the following information:
Loading zlib: okusing local package: pear ............. okusing local package: archive_tar ...... okusing local package: lele_getopt .... okusing local package: xml_rpc .......... okbootstrapping: pear ................... (local) okbootstrapping: archive_tar ............ (local) okbootstrapping: lele_getopt ......... (local) okdownloading package: DB ............... okdownloading package: net_socket ....... OK Downloading package: net_smtp ......... okdownloading package: Mail ............. okdownloading package: xml_parser ....... okdownloading package: phpunit .......... okextracting installer .................. okinstall OK: pear 1.3.1install OK: archive_tar 1.2 install OK: lele_getopt 1.2 install OK: xml_rpc 1.1.0install OK: DB 1.6.8install OK: net_socket 1.0.5install OK: net_smtp 1.2.6install OK: Mail 1.1.4 Install OK: xml_parser 1.2.4install OK: phpunit 1.2.0 ************************************** ***************************** warning! The specified de_path defined in the currently used PHP. INI does notcontain the pear PHP Directory you just specified: <D:/software/Wamp/PHP/pear> If the specified directory is also not in the specified de_path used byyour scripts, you will have problems getting any pear packages working. current include path :.; c:/PhP5/pearconfigured Directory: D:/software/Wamp/PHP/pearcurrently used PHP. INI (guess): Press enter to continue: download and install (Note: Make sure your computer is connected to the Internet so that pear can download the required class library ),
Press enter again.Display: The 'pear 'command is now at your service at D:/software/Wamp/PHP/pear. bat ** the 'pear 'command is not currently in your path, so you need to ** use 'd:/software/Wamp/PHP/pear. bat 'until you have added ** D:/software/Wamp/php' to your path environment variable. run it without parameters to see the available actions, try 'pear list' to see what packages are installed, or 'pear help' for help. for More information about pear, see: http://pear.php.net/faq.php http://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt? P = 1 http://pear.php.net/manual/ thanks for using go-pear! * Windows environment variables * For convenience, a reg file is available under D:/software/Wamp/PHP/pear_env.reg. this file creates env variables for the current user. double-click this file to add it to the current user registry. press any key to continue... press any key to close the Command Prompt window. Finally, go to the Apache installation directory and open PHP. INI, find :;;;;;;;;;;;;;;;;;;;;;;;;;; paths and directories; Unix: "/path1:/path2 "; include_path = ". :/PHP/shortdes "; windows:"/path1;/path2 "; include_path = ".; c:/PHP/uplodes "change the last line:
Include_path = ".; D:/software/Wamp/PHP/Pear"Save and exit.
Note: D:/software/Wamp/PHP/Pear
This directory depends on PHP/Pear
Enter the actual installation directory.Well, Here pear has been installed, is it very simple, basically run the go-pear.bat, one way to press ENTER can be.
3. install and use Pear
Spreadsheet_excel_writer
Excel library generation
Table
If you have never used pear, you may not be familiar with pear. Here is a simple example. First, go to the PHP installation directory. Run the following command:
Pear download olepear download spreadsheet_excel_writer Description: pear download package indicates to download the related package. Pear install OLE-0.5.tgzpear install Spreadsheet_Excel_Writer-0.8.tgz
Note: pear install packagename indicates the packagename for installation. For more pear commands and meanings, run pear. Run pear list after installation. If the following two lines are displayed, the installation is successful.
Ole 0.5 betaspreadsheet_excel_writer 0.8 beta. Then we create a test. php file in the WWW directory. The content is as follows: <? PHP shortde_once "spreadsheet/EXCEL/writer. PHP "; $ XLS = & New spreadsheet_excel_writer (); $ XLS-> send (" test.xls "); $ sheet = & $ XLS-> addworksheet ('test results '); $ sheet-> write (, 12); $ sheet-> write (, "Hallo, ich bin ein text "); $ format = & $ XLS-> addformat (); $ format-> setbold (); $ format-> setcolor ("green"); $ sheet-> write (1, 1, "Hallo, ich bin formatiert", $ format); $ XLS-> close ();?>
Then run the command directly. The IE browser will display a dialog box requesting to download the test.xls file. After downloading the file, you can view the generated Excel file. For details about the Excel table format syntax generated by spreadsheet_excel_writer, refer to the official pear manual. Well, our pear journey is over now. Are you interested in pear now? Don't try again!