|
Custom Search
| |
|
Inside This Article
Install all PEAR packages by yourself After you install PEAR on Windows for development use, you will eventually need to install it on your web hosting account for production use. There are two choices when installing PEAR.
Install all PEAR packages In this case, you are in full control of the entire PEAR packages installation, including PEAR Base System and any additional packages you need. Step #1: Install PEAR Base System 1.1 Download Download PEAR Base System Click the link above to open the download page. The version you download may be newer. 1.2 Once you have the package downloaded locally, extract it. You should have a folder called PEAR-X.X.X. In my case it's PEAR-1.9.1 To unzip, you can use open source file archiver 7-Zip.1.3 Drill down to folder PEAR-X.X.X until you find a folder called PEAR. 1.4 Next connect to your web hosting account by FTP program. 1.5 Create a new folder called PEAR in your web hosting account's home directory. It does not have to be in the root of your web directory (where public_html is). It's a good idea to create include directory one level above the public_html folder so that sensitive files are placed outside the publicly accessible web folder (where public_html is) - just an extra precaution. To understand fully about how to create include path, refer to article Five ways to create include path for PHP. 1.6 Select all files and sub-folders in PEAR folder on your computer and upload them to the PEAR folder you just created on your web host. Step #2: Create PEAR include path. Depends on how your web hosting company set up their web server, you can include PEAR in two different ways:
Step #3: Test if PEAR has been installed correctly. The best way to test is actually use a PEAR class to do something. We will use PEAR's text_highlighter class to display colored PHP code on a web page. 3.1 Download PEAR Text_Highlighter package The file I downloaded was Text_Highlighter-0.7.1.tgz 3.2 After unzip the package, rename the folder Text_Highlighter-0.7.1 to Text. To unzip, you may want to use popular open source file archiver 7-Zip. It looks like this after rename: Inside the Text folder, there is a Highlighter folder and a PHP file Highlighter.php. 3.3 Upload the folder Text from your computer to PEAR directory (created in step 1.5 and 1.6) in your web hosting account's home directory. This will add the Text Highlighter package to the PEAR code library and it's ready to be used. 3.4 Create the style sheet. Find the file sample.css in folder Text and upload it to your website root directory (where public_html is). On GeeksEngine, it's copied to http://www.geeksengine.com/sample.css 3.5 Create a PHP page and save it as test-pear.php in your localhost website. On GeeksEngine, it's at http://www.geeksengine.com/test-pear.php 3.6 Open test-pear.php in your text editor and add the following code. The code displays colored PHP code on a web page.
<?
echo "<link rel='stylesheet' type='text/css' href='sample.css'>"; // Include Highlighter class require_once("Text/Highlighter.php"); // This is the code we want to display $code = "<? // This is a test page for PEAR Text_Highlighter package \$message = \"Hello, world!\"; echo \$message; ?>"; // What to display - PHP code $what = "php"; // Define the class $highlighter =& Text_Highlighter::factory($what); // Call highlight method to display the code to web browser echo $highlighter->highlight($code); ?> 3.7 Display test-pear.php page. Open your web browser and view test-pear.php on your site. If you can see the colored PHP code as shown below, you have successfully installed PEAR base library. To use any other packages, just download and add them to PEAR directory on your web host home directory.
Next, read Part II of this article Use the hosting company's PEAR installation. |
Copyright © 2024 GeeksEngine.com. All Rights Reserved. This website is hosted by HostGator. No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it. |
Home | Feedback | Terms of Use | Privacy Policy |