PHP PEAR

PHP PEAR

  • PHP PEAR Manual
  • PEAR MDB2
  • Manual installation of PEAR Packages
  • PEAR DB Package
  • define variable: PHP_PEAR_INSTALL_DIR for the command line tool pear to check the pear directory
  • PHP PEAR at PHP’s CVS Web
  • install beta package in PEAR
    pear install -beta

  • Install a local copy of PEAR library for shared host enviornment
    1. For PEAR 1.4+
    2. Create a local config file:
      pear config-create [base-path] [/path/pearrc]

    3. Initial install base on the config file, files will put to base-path:
      pear -c /path/pearrc install Archive_Tar PEAR Console_Getopt XML_RPC

    4. Using the local pear from commandline:
      pear -c /path/pearrc [command]

    5. Using the local pear from apache conf:
      php_value include_path “.:/base-path"

    6. Using the local pear from inside php:
      ini_set('include_path', '~/pear/lib' . PATH_SEPARATOR  . ini_get('include_path'));
      
      // From PHP 4.3.0 onward, you can use the following,
      // which especially useful on shared hosts:
      set_include_path('~/pear/lib' . PATH_SEPARATOR . get_include_path());
      

PHP Links

OS Commerce

Socket Programming

Json Support

  • JSON (JavaScript Object Notation)
  • Steps to enable json extension in RHEL 5/CentOS 5
    Installation steps on CentOs 5.x include
    
    # yum install php-devel
    # yum install php-pear
    # yum install gcc
    # pear install pecl/json
    
    # cd /etc/php.d
    # echo "extension=json.so" > json.ini
    # service httpd restart
    
    After that phpinfo() would output
    
    json support     enabled
    json version     1.2.1 
    

PHP PDO

  • Experience (2011-04-27)
    • Serious bug in mysql, rowCount return no result
    • Run FetchAll() 2 times will generate exception error HY000 2050
  • Introduction to PHP PDO
  • PDO versus MDB2
    Problem: PDO could not start a new session before stop the current session

General

Framework

Portals / Articles

Portals

PHP Articles

Non PHP Articles (To be moved somewhere)

Forums

PHP and Unicode

PHP Extensions


PECL Classes


PEAR Classes

  • Tree
  • Pager_Pager (Pagination for database w/o limit function or raw data)
  • DB_Pager (Pagination for database)
  • DB_DataObject (code generation from SQL Database tables)
  • Contact_Vcard_Build (a class to create vCard)
  • HTML_QuickForm (A very complete form class)
    • Example for enable Client Side JavaScript valiation
      Add ‘client’ to the 5th element of the AddRule function

    • List of QuickForm rules (as of v3.2.2)
      ‘required’ => array(‘html_quickform_rule_required’, ‘HTML/QuickForm/Rule/Required.php’),
      ‘maxlength’ => array(‘html_quickform_rule_range’, ‘HTML/QuickForm/Rule/Range.php’),
      ‘minlength’ => array(‘html_quickform_rule_range’, ‘HTML/QuickForm/Rule/Range.php’),
      ‘rangelength’ => array(‘html_quickform_rule_range’, ‘HTML/QuickForm/Rule/Range.php’),
      ’email’ => array(‘html_quickform_rule_email’, ‘HTML/QuickForm/Rule/Email.php’),
      ‘regex’ => array(‘html_quickform_rule_regex’, ‘HTML/QuickForm/Rule/Regex.php’),
      ‘lettersonly’ => array(‘html_quickform_rule_regex’, ‘HTML/QuickForm/Rule/Regex.php’),
      ‘alphanumeric’ => array(‘html_quickform_rule_regex’, ‘HTML/QuickForm/Rule/Regex.php’),
      ‘numeric’ => array(‘html_quickform_rule_regex’, ‘HTML/QuickForm/Rule/Regex.php’),
      ‘nopunctuation’ => array(‘html_quickform_rule_regex’, ‘HTML/QuickForm/Rule/Regex.php’),
      ‘nonzero’ => array(‘html_quickform_rule_regex’, ‘HTML/QuickForm/Rule/Regex.php’),
      ‘callback’ => array(‘html_quickform_rule_callback’, ‘HTML/QuickForm/Rule/Callback.php’),
      ‘compare’ => array(‘html_quickform_rule_compare’, ‘HTML/QuickForm/Rule/Compare.php’)

    • compare rule example
    • Custom rules example (add a compare function in QuickForm 2.x)
      function cmpPass($element, $pass2val)
      {
      global $form;
      $pass1val = $form->getElementValue(‘passwd1’);
      return ($pass1val == $pass2val);
      }
      $form->registerRule(‘compare’, ‘function’, ‘cmpPass’);
      $form->addElement(‘password’, ‘passwd1’, ‘Enter password’);
      $form->addElement(‘password’, ‘passwd2’, ‘Confirm password’);
      $form->addElement(‘submit’, ‘submit’, ‘submit’);
      $form->addRule(‘passwd1’, ‘Please enter password’, ‘required’);
      $form->addRule(‘passwd2’, ‘Please confirm password’, ‘required’);
      $form->addRule(‘passwd2’, ‘Passwords are not the same’, ‘compare’, ‘function’);

    • PEAR HTML_QuickForm Getting Started Guide
    • pookey.co.uk – HTML_QuickForm Tutorial
  • The Log Package

PHP Libraries / 3rd party applications

PHP Applications

Troubleshooting