Zero logo

PHP - PEAR Web Frontend

The PHP Extension and Application Repository (or PEAR for short) contains re-usable code. The PEAR core has been preinstalled (Module ZeroXI_pear_1_0_0) this page covers the PEAR Web Frontend

Open PEAR Web Frontend

You can access the web-front-end at any time using either of the following methods:

Method 1
Run the web-front-end from UniController menu as follows:

PHP > View Pear frontend

  

Method 2
Alternatively enter the following into your browser:

http://localhost/us_pear/index.php

Using PEAR Frontend

Open the PEAR front-end using one of the methods explaind above.

Installing PEAR packages is very easy. To confirm our PEAR installation is working and to demonstrate how to install packages, we will be using a package named HTML_QuickForm

Update the Channel Management system

Before downloading any package, update the Channel Management system

  • C) Click on Channel Management - Opens Registered Channels page.
  • From this page, click on Update All Channels

You will receive something similar this:

Updating channel "doc.php.net"
Update of Channel "doc.php.net" succeeded
Updating channel "pear.php.net"
Channel "pear.php.net" is up to date
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
Auto PEAR Install

Downloading modules

Downloading a known package (example HTML_QuickForm)

  • A) Click on Package Management - Opens management page.
  • Scroll down page to Quick-install a package
  • Enter package name HTML_QuickForm
  • Click Install
Auto PEAR Install
  • After a short time the package is installed.
  • Note the Warnings! We know this is an older package but want to use it anyway.
Auto PEAR Install
  • A) Click on Package Management - Opens management page.
  • New Installed packages are listed.

Although we intended to only download and install a single package, two were installed. The package HTML_QuickForm will not function without package HTML_Common; it depends on this being in place. In other words, when installing a package, all dependencies that do not exist are also installed.

Auto PEAR Install

Form - Test Script

Create a new text file named form.php with the following content and save to folder UniServerZ\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:
  • Start The Uniform Server
  • Type the following into a browser: http://localhost/form.php
  • Expected result is shown on right.
Form Test results

Where to next

Background information for installing Pear:

PHP - PEAR Auto Install go-pear - This page covers using go-pear that automats the installation process.

PHP - PEAR Manual Install - This page covers manual PEAR installation.