PEAR For The Masses

50 %
50 %
Information about PEAR For The Masses

Published on May 23, 2007

Author: schst

Source: slideshare.net

Description

Session about PEAR from the O'Reilly Open Source Convention 2004

PEAR for the masses Stephan Schmidt Metrix Internet Design GmbH, Germany O’Reilly Open Source Convention July 26–30, 2004

Agenda About the Speaker What is PEAR The Website Obtaining and Installing PEAR The PEAR Community Using PEAR Components Contributing to PEAR The Future of PEAR

About the Speaker

What is PEAR

The Website

Obtaining and Installing PEAR

The PEAR Community

Using PEAR Components

Contributing to PEAR

The Future of PEAR

About the speaker Working for Metrix Internet Design GmbH in Karlsruhe, Germany PHP since version 3 Co-founder of PHP Application Tools (www.php-tools.net) Member of the PEAR QA-Core Team Active Contributor to PEAR (Lead developer of 11 packages) Working on C-Extensions for PHP Regular speaker at conferences and author for various magazines

Working for Metrix Internet Design GmbH in Karlsruhe, Germany

PHP since version 3

Co-founder of PHP Application Tools (www.php-tools.net)

Member of the PEAR QA-Core Team

Active Contributor to PEAR (Lead developer of 11 packages)

Working on C-Extensions for PHP

Regular speaker at conferences and author for various magazines

What is PEAR? Of course, but also…

Of course, but also…

What is PEAR? PEAR is short for P HP E xtension and A pplication R epository, and was founded in 1999 by Stig S. Bakken. PEAR is several things: A structured library of open-source code for PHP developers. The PEAR website The PEAR Community and Mailinglists The PEAR installer

PEAR is short for P HP E xtension and A pplication

R epository, and was founded in 1999 by Stig S.

Bakken.

PEAR is several things:

A structured library of open-source code for PHP developers.

The PEAR website

The PEAR Community and Mailinglists

The PEAR installer

The Code Library Organized in Categories (Database, File Formats, HTTP, Images, XML, …) Categories contain Packages (HTTP_Client, MP3_ID, XML_Parser, …) Packages are separate projects with their own development team, release cycle and documentation Relations between packages solved by dependencies (HTTP_Client needs HTTP_Request)

Organized in Categories (Database, File Formats, HTTP, Images, XML, …)

Categories contain Packages (HTTP_Client, MP3_ID, XML_Parser, …)

Packages are separate projects with their own development team, release cycle and documentation

Relations between packages solved by dependencies (HTTP_Client needs HTTP_Request)

PEAR packages Currently more than 230 packages are available Packages contain PHP Files (mostly OOP-Code) Examples Unit Tests (either phpt or PHP_Unit) Documentation (in plain text) Releases have a state (devel, alpha, beta, stable) to indicate the maturity of the package All packages and releases are stored in one central database at pearweb. Based on open licenses like the PHP or LGPL licenses (no GPL allowed)

Currently more than 230 packages are available

Packages contain

PHP Files (mostly OOP-Code)

Examples

Unit Tests (either phpt or PHP_Unit)

Documentation (in plain text)

Releases have a state (devel, alpha, beta, stable) to indicate the maturity of the package

All packages and releases are stored in one central database at pearweb.

Based on open licenses like the PHP or LGPL licenses (no GPL allowed)

What is PEAR? PEAR is short for P HP E xtension and A pplication R epository, and was founded in 1999 by Stig S. Bakken. PEAR is several things: A structured library of open-source code for PHP developers. The PEAR website The PEAR Community and Mailinglists The PEAR installer

PEAR is short for P HP E xtension and A pplication

R epository, and was founded in 1999 by Stig S.

Bakken.

PEAR is several things:

A structured library of open-source code for PHP developers.

The PEAR website

The PEAR Community and Mailinglists

The PEAR installer

The PEAR Website

The PEAR Website (2) Allows users to browse categories and packages using the package browser Provides information about each package Short description Maintainers List of releases Changelog Auto-generated API documentation Each release may be downloaded as a TGZ archive

Allows users to browse categories and packages using the package browser

Provides information about each package

Short description

Maintainers

List of releases

Changelog

Auto-generated API documentation

Each release may be downloaded as a TGZ archive

The PEAR Website (3) The Website also provides: Online documentation (mainly English, some translations) Downloadable documentation Bug Tracking System Account list to browse all developers Possibility to contact each maintainer using an HTML form Support resources (links to mailing list archives and tutorials)

The Website also provides:

Online documentation (mainly English, some translations)

Downloadable documentation

Bug Tracking System

Account list to browse all developers

Possibility to contact each maintainer using an HTML form

Support resources (links to mailing list archives and tutorials)

The PEAR Website for Developers Developer features of the website include: Online proposal system for new packages (PEPr) Registering new packages Uploading new releases Editing package information and maintainers The PEAR Website will promote new packages by announcing them on the website and mailing list.

Developer features of the website include:

Online proposal system for new packages (PEPr)

Registering new packages

Uploading new releases

Editing package information and maintainers

The PEAR Website will promote new packages by

announcing them on the website and mailing list.

Interlude: What is PECL? P HP E xtension C ommunity L ibrary Sister project of PEAR for C Extensions Uses the PEAR infrastructure and installer Governed by King Wez (Furlong) Official repository for PHP Extensions Long term plan includes moving all PHP Extensions from the source tree to PECL to allow separate release cycles

P HP E xtension C ommunity L ibrary

Sister project of PEAR for C Extensions

Uses the PEAR infrastructure and installer

Governed by King Wez (Furlong)

Official repository for PHP Extensions

Long term plan includes moving all PHP Extensions from the source tree to PECL to allow separate release cycles

What is PEAR? PEAR is short for P HP E xtension and A pplication R epository, and was founded in 1999 by Stig S. Bakken. PEAR is several things: A structured library of open-source code for PHP developers. The PEAR website The PEAR Community and Mailinglists The PEAR installer

PEAR is short for P HP E xtension and A pplication

R epository, and was founded in 1999 by Stig S.

Bakken.

PEAR is several things:

A structured library of open-source code for PHP developers.

The PEAR website

The PEAR Community and Mailinglists

The PEAR installer

PEAR Community No strict hierarchy All developers vote on important decisions Mailinglists for all institutions [email_address] [email_address] [email_address] PEAR Group 7 developers Developers Quality Assurance Team Doc Team Website Team

No strict hierarchy

All developers vote on important decisions

Mailinglists for all institutions

[email_address]

[email_address]

[email_address]

PEAR Quality Assurance Ensures high quality of PEAR by enforcing several rules Code must conform to coding standards intuitive API packages should be designed with extensibility in mind visibility of properties and methods No backward compatibility breaks allowed in the same major version Unit tests and documentation are requirements Improved code by peer review

Ensures high quality of PEAR by enforcing several rules

Code must conform to coding standards

intuitive API

packages should be designed with extensibility in mind

visibility of properties and methods

No backward compatibility breaks allowed in the same major version

Unit tests and documentation are requirements

Improved code by peer review

What is PEAR? PEAR is short for P HP E xtension and A pplication R epository, and was founded in 1999 by Stig S. Bakken. PEAR is several things: A structured library of open-source code for PHP developers. The PEAR website The PEAR Community and Mailinglists The PEAR installer

PEAR is short for P HP E xtension and A pplication

R epository, and was founded in 1999 by Stig S.

Bakken.

PEAR is several things:

A structured library of open-source code for PHP developers.

The PEAR website

The PEAR Community and Mailinglists

The PEAR installer

The PEAR Installer PEAR is installed by default since PHP4.3 If not installed, use http://go-pear.org (interactive script that installs all required components) Various frontends are available Command Line Interface (default) Webinterface GTK Frontend All frontends provide the same commands

PEAR is installed by default since PHP4.3

If not installed, use http://go-pear.org (interactive script that installs all required components)

Various frontends are available

Command Line Interface (default)

Webinterface

GTK Frontend

All frontends provide the same commands

PEAR Installer (CLI)

PEAR Installer (Web)

PEAR Installer Features Downloads and installs PEAR packages and C Extensions Creates packages that can be uploaded at the PEAR Website Automatically checks dependencies on other packages, PHP version and PHP extensions Only installs and upgrades packages of your preferred state (stable, beta, alpha, devel) Can create and install third-party packages

Downloads and installs PEAR packages and C Extensions

Creates packages that can be uploaded at the PEAR Website

Automatically checks dependencies on other packages, PHP version and PHP extensions

Only installs and upgrades packages of your preferred state (stable, beta, alpha, devel)

Can create and install third-party packages

PEAR Installer commands $ pear install <packagename> downloads and installs the package $ pear uninstall <packagename> uninstalls the package $ pear list lists all installed packages $ pear list-upgrades lists packages that have new versions $ pear config-show displays installer configuration … plus some more commands, mainly for developers

$ pear install <packagename>

downloads and installs the package

$ pear uninstall <packagename> uninstalls the package

$ pear list lists all installed packages

$ pear list-upgrades lists packages that have new versions

$ pear config-show displays installer configuration

… plus some more commands, mainly for developers

PEAR Installer internals Uses XML-RPC to communicate with the PEAR Website Downloads the tgz archive of a package The package.xml file describes the content of the package as well as any dependencies on other packages Extracts all needed files to your local PEAR installation folders and stores information in the PEAR registry Currently being refactored by Greg Beaver

Uses XML-RPC to communicate with the PEAR Website

Downloads the tgz archive of a package

The package.xml file describes the content of the package as well as any dependencies on other packages

Extracts all needed files to your local PEAR installation folders and stores information in the PEAR registry

Currently being refactored by Greg Beaver

Shared Hosts PEAR mostly not installed No shell access Manual installation of PEAR All packages contain standard PHP code Download tar.gz from website Unpack Upload to shared host Set include path (.htaccess or ini_set())

PEAR mostly not installed

No shell access

Manual installation of PEAR

All packages contain standard PHP code

Download tar.gz from website

Unpack

Upload to shared host

Set include path (.htaccess or ini_set())

PEAR Filesystem Structure All files are stored in one directory on your server Can be set using pear config-set (defaults to /usr/share/pear) Should not be in your webroot Add it to your include path Classnames map to directory structure: HTTP_Request class is in /usr/share/pear/HTTP/Request.php Special folders for tests and docs: /usr/share/pear/tests/XML_Parser/ /usr/share/pear/docs/HTTP_Server

All files are stored in one directory on your server

Can be set using pear config-set (defaults to /usr/share/pear)

Should not be in your webroot

Add it to your include path

Classnames map to directory structure:

HTTP_Request class is in /usr/share/pear/HTTP/Request.php

Special folders for tests and docs:

/usr/share/pear/tests/XML_Parser/

/usr/share/pear/docs/HTTP_Server

Using PEAR packages Classes may be included by using <?PHP require_once 'HTTP/Request.php' ; ?> A lot of packages use a driver based architecture: <?PHP require_once 'DB.php' ; $dbh = DB::connect( 'mysql://user:pass@host' ); ?> Unified error handling in all packages using PEAR_Error

Classes may be included by using <?PHP require_once 'HTTP/Request.php' ; ?>

A lot of packages use a driver based architecture: <?PHP require_once 'DB.php' ; $dbh = DB::connect( 'mysql://user:pass@host' ); ?>

Unified error handling in all packages using PEAR_Error

PEAR error handling Errors are instances of PEAR_Error that contain Error message and optional code function backtrace to help with debugging Error handling can be set globally or for single instances print the message die on error trigger PHP error handle it using a callback Will be replaced with PEAR_ErrorStack and/or exceptions in PHP5

Errors are instances of PEAR_Error that contain

Error message and optional code

function backtrace to help with debugging

Error handling can be set globally or for single instances

print the message

die on error

trigger PHP error

handle it using a callback

Will be replaced with PEAR_ErrorStack and/or exceptions in PHP5

Example 1 - Database abstraction <?php require_once 'DB.php'; $db =&DB::connect( 'mysql://usr:pw@localhost/dbnam' ); if (DB::isError( $db )) { die ( $db ->getMessage()); } $res =& $db ->query( 'SELECT * FROM mytable' ); while ( $row = $res ->fetchRow()) { echo $row [0] . &quot; &quot; ; } ?>

<?php

require_once 'DB.php';

$db =&DB::connect( 'mysql://usr:pw@localhost/dbnam' );

if (DB::isError( $db )) {

die ( $db ->getMessage());

}

$res =& $db ->query( 'SELECT * FROM mytable' );

while ( $row = $res ->fetchRow()) {

echo $row [0] . &quot; &quot; ;

}

?>

Example 1 - Database abstraction Advantages of using PEAR::DB Easy switching between several database backends (currently 13 database types are supported) Very intuitive to use Errors can be checked with DB::isError( $foo ) Improves compatibility between databases by lowercasing fieldnames, trimming return values, etc. Emulates prepare/execute for databases that do not support this natively

Advantages of using PEAR::DB

Easy switching between several database backends (currently 13 database types are supported)

Very intuitive to use

Errors can be checked with DB::isError( $foo )

Improves compatibility between databases by lowercasing fieldnames, trimming return values, etc.

Emulates prepare/execute for databases that do not support this natively

Example 2 - Beautifying XML <root> <section title = &quot;This is an example&quot; id = &quot;myId&quot; author = &quot;Stephan Schmidt&quot; ><para> Although this document is wellformed, it is <em type = &quot;strong&quot; > not </em> looking very nice. </para> <para> But there's help, as PEAR::XML_Beautifier is able to beautify any valid XML document. </para></section> </root>

<root>

<section title = &quot;This is an example&quot; id = &quot;myId&quot;

author = &quot;Stephan Schmidt&quot; ><para>

Although this document is wellformed, it is <em

type = &quot;strong&quot; > not </em> looking very nice.

</para>

<para>

But there's

help, as PEAR::XML_Beautifier

is

able to beautify any valid XML document.

</para></section>

</root>

Example 2 - Beautifying XML <?PHP require_once 'XML/Beautifier.php' ; $fmt = & new XML_Beautifier(); $result = $fmt ->formatFile( 'example1.xml', 'result.xml' ); if (PEAR::isError( $result )) { echo $result ->getMessage(); exit (); } ?>

<?PHP

require_once 'XML/Beautifier.php' ;

$fmt = & new XML_Beautifier();

$result = $fmt ->formatFile( 'example1.xml', 'result.xml' );

if (PEAR::isError( $result )) {

echo $result ->getMessage();

exit ();

}

?>

Example 2 - Beautifying XML <root> <section author = &quot;Stephan Schmidt&quot; id = &quot;myId&quot; title = &quot;This is an example&quot; > <para> Although this document is wellformed, it is <em type = &quot;strong&quot; > not </em> looking very nice. </para> <para> But there&apos;s help, as … valid XML document. </para> </section> </root>

<root>

<section author = &quot;Stephan Schmidt&quot; id = &quot;myId&quot; title = &quot;This is an example&quot; >

<para>

Although this document is wellformed, it is

<em type = &quot;strong&quot; > not </em>

looking very nice.

</para>

<para> But there&apos;s help, as … valid XML document. </para>

</section>

</root>

Other interesting PEAR packages phpDocumentor, a tool for generating API documentation from JavaDoc-style inline comments SOAP, complete client and server SOAP library PHPUnit, framework for Unit tests Spreadsheet_Excel_Writer, excel spreadsheet generator without any need for external libraries File_PDF, PDF generator without any need for external libraries XML_Serializer, allround XML reader/writer

phpDocumentor, a tool for generating API documentation from JavaDoc-style inline comments

SOAP, complete client and server SOAP library

PHPUnit, framework for Unit tests

Spreadsheet_Excel_Writer, excel spreadsheet generator without any need for external libraries

File_PDF, PDF generator without any need for external libraries

XML_Serializer, allround XML reader/writer

Who is using PEAR? Horde (Framework) TikiWiki (Wiki application) S9Y (Weblog application) Savant (Template engine) Seagull PHP Framework (Framework) patUser (PHP Application Tools) YAWP (Application framework) Yawiki (Wiki application) A lot of commercial applications

Horde (Framework)

TikiWiki (Wiki application)

S9Y (Weblog application)

Savant (Template engine)

Seagull PHP Framework (Framework)

patUser (PHP Application Tools)

YAWP (Application framework)

Yawiki (Wiki application)

A lot of commercial applications

Contributing to PEAR There are several ways to contribute: By submitting bug reports or patches By translating the documentation By contributing to the documentation By creating new packages

There are several ways to contribute:

By submitting bug reports or patches

By translating the documentation

By contributing to the documentation

By creating new packages

Including new packages Make sure that the functionality is not in PEAR already Make sure you follow the PEAR coding styles and naming standards Make sourcecode, examples and docs available Propose the package in PEPr Discuss your proposal on pear-dev Call for votes Register your package Upload release

Make sure that the functionality is not in PEAR already

Make sure you follow the PEAR coding styles and naming standards

Make sourcecode, examples and docs available

Propose the package in PEPr

Discuss your proposal on pear-dev

Call for votes

Register your package

Upload release

Creating PEAR packages Adjust &quot;package.xml&quot; Contains information about package, state, maintainer(s), dependencies, changelog and included files PEAR_PackageFileManager will help you Open a shell and move to the package folder Run pear package Test the resulting package Upload it to pear.php.net

Adjust &quot;package.xml&quot; Contains information about package, state, maintainer(s), dependencies, changelog and included files

PEAR_PackageFileManager will help you

Open a shell and move to the package folder

Run pear package

Test the resulting package

Upload it to pear.php.net

The Future of PEAR Channel support Allows you to distribute your own application using PEAR by providing a package server Better support for PHP5 Improved error handling Interfaces Exceptions Improved Quality Assurance

Channel support

Allows you to distribute your own application using PEAR by providing a package server

Better support for PHP5

Improved error handling

Interfaces

Exceptions

Improved Quality Assurance

Thank you! Thanks for your attention, feel free to ask any questions now. Links: http://www.php-tools.net (the slides) http://pear.php.net http://pecl.php.net [email_address]

Thanks for your attention, feel free to ask any

questions now.

Links:

http://www.php-tools.net (the slides)

http://pear.php.net

http://pecl.php.net

[email_address]

 

Add a comment

Related presentations

Related pages

St. Margaret of Antioch - Pearl River, NY

will collect non perishable food at all Masses on January 7 & 8. ...
Read more

Kidney (Renal) Mass

Most of the kidney (renal) masses referred to the Division of Urology at Washington University School of Medicine are found incidentally when patients are ...
Read more

NASA - Most Changes in Earth's Shape Due to Changes in Climate

The oscillation also brings changes in the location of the cold and warm water masses that can alter the path of the jet stream, ...
Read more

The Mass of Fruits - Math in English

The Mass of Fruits apple pear lemon The mass of the apple is units. The mass of the is 4 units. The is 2 units heavier than the lemon. The total mass of ...
Read more

USER MANUAL ROPE PEAR SOCKETS - Mennens Belgium

NEMAG Rope Pear Sockets are cast out of GX 120 Mn 12, an austenitic manganese ... metallic casting masses the NEMAG Rope Pear Socket must be preheated.
Read more

St. Joseph Church: Welcome to Saint Joseph Church

Welcome Fr Geoffrey Baraan! Rev. Geoffrey Baraan will serve St. Joseph Church and School in Pinole as Pastor, beginning July 1, 2016. Fr. Geoff has been ...
Read more

Guy Pearce - IMDb

Guy Pearce, Actor: Memento. Guy Edward Pearce was born 5 October, 1967 in Cambridgeshire, England, UK to Anne (Pickering) and Stuart Graham Pearce.
Read more