Coral: php pear manual install

PHP - PEAR Manual Install

This page covers an alternative to automatically installing PEAR using a script!

Using a script to automatically install PEAR makes the process very easy. However there is a drawback that this process masks what is going on behind the scenes. Manually installing PEAR provides greater control, flexibility and exposes this hidden detail. The following covers manually installing PEAR, along with one of its components (classes) for testing.


UniServer 8-Coral
  Home
  Quick Start
  General
  Apache
  MySQL
» PHP
  MSMTP
  CRON
  DtDNS
  Db Backup
  Perl
  Main Index

Install PEAR core package

The first requirement is to install the PEAR core package. This core package is used by all other packages to extend their functionality.

Note: All PEAR files are distributed using double compression (Unix standard). These have a file extension of tgz. To uncompress these files you can install the file archiver 7-Zip. Alternatively, you can use the portable version from Portable Apps.

Download and Extract PEAR core package

  • A) Create a new folder. It can be any name, for example pear_temp
  • Download the latest PEAR core package (PEAR-1.9.4.tgz - see top right "For manual installation only") - Save to folder pear_temp
  • A) Start 7-Zip and navigate to folder pear_temp.
  • A) Highlight file PEAR-1.9.4.tgz (left mouse click), click Extract (top menu button) and click OK in pop-up
  • B) A new folder (PEAR-1.9.4) is created. Navigate into this folder.
  • B) Highlight file PEAR-1.9.4.tar (left mouse click), click Extract and click OK
  • You can now close 7-Zip.

That completes file extraction. You should have a folder structure as shown on the right.

  • C) Using explorer, navigate into folder PEAR-1.9.4 (last one in tree with this name).
  • From this folder, copy files PEAR.php and PEAR5.php to folder PEAR D)

 

The PEAR core package is now ready to install on The Uniform Server.

Top'

Install core package on The Uniform Server

The Uniform Server has been pre-configured to run PEAR from a specific location UniServer\home\us_pear. This folder contains files appropriate for automatic installation; with the exception of file .htaccess its contents requires deleting. Install PEAR as follows:

  • E) Navigate into folder UniServer\home\us_pear.
    With the exception of file .htaccess, delete its content.
  • D) Copy folder pear_temp\PEAR-1.9.4\PEAR-1.9.4\PEAR-1.9.4\PEAR
    E) to folder UniServer\home\us_pear
  • Folder structure as show on right

 

Top

Installing PEAR packages

Installing PEAR packages is relatively easy. Download and extract the package and install it to the PEAR folder. To confirm our PEAR installation is working and to demonstrate how to install packages we will be using a package named QuickForm.

A Quick tour of PEAR repository

  • First port of call is List Packages All packages have been grouped into sections. The number to the right of each section title is the total packages in this group.
  • We are interested in the QuickForm package which comes under section HTML This page contains a list of all packages in this section.
  • Scrolling down the page you will see enteries HTML_QuickForm, HTML_QuickForm2, HTML_QuickForm_advmultiselect etc. To the right is displayed the current status.
  • Scroll to package HTML_QuickForm and click link.
  • Scroll down the page and you will find an important section named Dependencies. For HTML_QuickForm you will see it requires HTML_Common. We do require this because our current installation contains no additional installed packages. The dependencies section provides a quick link; clicking the link HTML_Common will take you to the download page.
  • At the top of each package page are the following links, Main, Download, Documentation, Bugs, Trackbacks. Generally you can find examples of how to use a package in the documentation. Alternatively, you can search the Internet. The download link opens a download page where you can download files for manual installation.

Top

Installing Dependencies

  • G) Create a new folder or use existing one; for example pear_temp
  • Download latest HTML_Common package (HTML_Common-1.2.5.tgz top right manual installation only) - Save to folder pear_temp
  • G) Start 7-Zip and navigate to folder pear_temp.
  • G) Highlight file HTML_Common-1.2.5.tgz (left mouse click), click Extract (top menu button) and click OK in the pop-up
  • H) A new folder (HTML_Common-1.2.5) is created. Navigate into this folder.
  • H) Highlight file HTML_Common-1.2.5.tar (left mouse click), click Extract and click OK
  • You can now close 7-Zip.
  • I) That completes file extraction. Installation requires installing a single file contained in folder HTML_Common-1.2.5

 

Where to install this file? Each distribution contains a file package.xml. Inside this file look for baseinstalldir which tells you the folder to install to. For this package it is HTML (baseinstalldir="HTML")

  • F) Using explorer, navigate into folder UniServer\home\us_pear\PEAR
  • Create a new folder HTML
  • Using explorer navigate into folder HTML_Common-1.2.5 (last one in tree with this name).
  • From this folder, copy file Common.php to folder UniServer\home\us_pear\PEAR\HTML

Top

Installing PEAR Package - QuickForm

  • J) Create a new folder or use existing one, for example pear_temp
  • Download latest QuickForm package (HTML_QuickForm-3.2.12.tgz top right manual installation only) - Save to folder pear_temp
  • J) Start 7-Zip and navigate to folder pear_temp.
  • J) Heighlight file HTML_QuickForm-3.2.12.tgz (left mouse click), click Extract (top menu button) and click OK in pop-up
  • K) A new folder (HTML_QuickForm-3.2.12) is created. Navigate into this folder.
  • K) Heighlight file HTML_QuickForm-3.2.12.tar (left mouse click), click Extract and click OK
  • You can now close 7-Zip.
  • L) That completes file extraction. Installation requires installing content of folder HTML_QuickForm-3.2.12

 

Where to install this file? Each distribution contains a file package.xml inside this file look for baseinstalldir which tell you the folder to install to. For this package it is HTML (baseinstalldir="HTML" name="/")

  • We have already create the base folder HTML in folder UniServer\home\us_pear\PEAR
  • L) Using explorer navigate into folder HTML_QuickForm-3.2.12 (last one in tree with this name).
  • From this folder copy its content to folder UniServer\home\us_pear\PEAR\HTML

The Uniform Server's PEAR folder will now look like that shown on the right.

 

Top

Form - Test Script

Create a new text file named form.php with the following content and save to folder UniServer\www

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Pear HTML_QuickForm test</title>
  </head>
  <body>
  <?php
      require_once "HTML/QuickForm.php";

      $form = new HTML_QuickForm('frmTest', 'get');
      $form->addElement('header', 'MyHeader', 'Testing QuickForm');
      $form->addElement('text', 'MyTextBox', 'What is your name?');
      $form->addElement('reset', 'btnClear', 'Clear');
      $form->addElement('submit', 'btnSubmit', 'Submit');
      $form->display();

  ?>
  </body>
  </html>

Test:

 

Top

PEAR Alternate location

Although The Uniform Server uses a specific PEAR location, you can install to any location that suits your requirements. For example, you can copy PEAR folder to folder UniServer\usr\local\php or perform a manual installation directely to this folder. Adding packages to the PEAR folder has been covered in the above sections.

Change include path for PEAR

The include path in PHP’s configuration file php.ini requires changing to new PEAR folder location. There are three files to edit as follows:

  • UniServer\usr\local\php\php.ini
  • UniServer\usr\local\php\php.ini_development
  • UniServer\usr\local\php\php.ini_production

In each of the above files locate the following line:

include_path = ".;C:/UniServer/home/us_pear/PEAR"

And change to:

include_path = ".;UniServer/usr/local/php/PEAR"

Note 1:The path C:/UniServer may be different depending on where you extracted The Uniform Server, so change the paths accordingly.


Note 2: PHP always uses configuration file php.ini; the content of this file is selectable by a user. For example, when a user switches to development mode, contents of file php.ini_development are copied to php.ini

Top

Where to next

PHP PEAR - This page covers PEAR installation using go-pear, which is integrated into The Uniform Server’s structure.

Top