You are previewing The PEAR Installer Manifesto.
O'Reilly logo
The PEAR Installer Manifesto

Book Description

The PEAR Installer maintainer shows you the power of this code management and deployment system to revolutionize your PHP application development

  • Learn how to effectively organize your application development from the creator of the latest versions of the PEAR Installer, version 1.4.0 onwards

  • Bring the power of versioning and rollbacks to your live website

  • Embed the PEAR Installer in your web applications to manage plug-ins from a remote server

  • In Detail

    PEAR stands for PHP Extension and Application Repository, and its primary purpose is to support code re-use. PEAR provides both an advanced installer and a code repository at PEAR code is organized into discrete re-usable components called packages. A package consists of a group of files and a descriptor file called package.xml that contains metadata about the package's contents, such as the package version, any special dependencies, and textual information such as the package description and authors.The software that transforms a package from an inert grouping of files into a dynamic software package is called the PEAR Installer and is itself a PEAR package. In other words, the PEAR Installer can be used to upgrade itself. It truly is a very powerful application.

    In short, the PEAR Installer is one of the most effective tools for managing a high-quality software library, high-quality applications, or high-quality websites.

    This book will show you a new way of organizing your PHP development, by leveraging the full power of the PEAR Installer. In a sense, the PEAR Installer is a step above a software design pattern, a meta-development pattern that can be used to systematically organize all of your PHP development.

    You will learn how to organize your code into packages using the package.xml format. You will learn about the revolutionary new PEAR Channel concept, and how to safely and reliably depend on external PHP libraries from sources such as and other PEAR channels. You will learn about the

    PEAR_PackageFileManager package, and how to customize individual installations of your PHP code through file roles, file tasks, and post-installation scripts.

    In addition, you will learn how to use the power of PEAR to manage your web projects with the PEAR installer to bring the power of versioning and rollbacks to your live website. The synergy of the PEAR Installer and a revision control system like CVS or Subversion is also explored in depth.

    Next, you will learn how to set up your own PEAR Channel for distributing PHP applications, both open-source and proprietary closed-source PHP applications that can be secured using technology already built into the PEAR Installer.

    Finally, you will learn how to embed the PEAR Installer inside your own web application in order to manage plug-ins from a remote server. The book covers in detail designing a custom plug-in system for a fictitious blog application. The plug-in system is used to manage templates, and the PEAR Installer is used to manage the details of querying the remote server for templates, handling dependencies between versioning, and doing the actual installation process as well.

    PEAR Installer is the preferred PHP software for installing PHP components. It can be used to easily ensure that the most powerful and up to date php software is installed and working on your server. This book reveals the full power of the PEAR Installer, presenting a new way of organizing your PHP application development and deployment.

    Table of Contents

    1. Copyright
    2. Credits
    3. About the Author
    4. About the Reviewers
    5. Preface
      1. What This Book Covers
      2. Conventions
      3. Reader Feedback
      4. Customer Support
        1. Downloading the Example Code for the Book
        2. Errata
        3. Questions
    6. 1. Acquiring PEAR: What is it and How do I Get It?
      1. A Democratic Innovation for PHP: PEAR Channels
      2. What is PEAR? A Code Repository or an Installer?
        1. PEAR Package Repository and PEAR Channel
        2. PEAR Installer
      3. Installing the PEAR Installer
        1. PEAR Bundled with PHP
        2. Installation for PHP Versions Older than 5.1.0
        3. Other Unofficial Sources
      4. Synchronizing to a Server with no Shell Access Using PEAR_RemoteInstaller
      5. Summary
    7. 2. Mastering PHP Software Management with the PEAR Installer
      1. Distributing Libraries and Applications
        1. Differences between Libraries and Applications from the Installer's Point of View
      2. Using Versioning and Dependencies to Help Track and Eliminate Bugs
        1. Versioning
        2. PEAR Packaging and Strict Version Validation
        3. Enterprise-Level Dependency Management
      3. Distribution and Upgrades for the End User
      4. An Overview of package.xml Structure
      5. Tags Shared between package.xml 1.0 and 2.0
        1. Package Metadata
          1. Package Name/Channel
          2. Maintainers (Authors)
          3. Package Description and Summary
        2. Basic Release Metadata
          1. Package Version
          2. Package Stability
          3. External Dependencies
            1. Simplifying XML Validation of package.xml
            2. Managing Trust of Dependencies
            3. Reliably Depending on PECL Packages
          4. Release Notes
          5. Release License
          6. Changelog
          7. File List, or Contents of the Package
      6. New Tags in package.xml
      7. File/Directory Attributes: name, role, and baseinstalldir
      8. Summary
    8. 3. Leveraging Full Application Support with the PEAR Installer
      1. package.xml Version 2.0: Your Sexy New Friend
      2. PEAR Channels: A Revolution in PHP Installation
      3. Application Support
        1. Introduction to Custom File Roles
          1. Creating PEAR_Installer_Role_Chiaramdb2schema Custom Role
          2. Full Range of Possible Custom File Roles
        2. Introduction to Custom File Tasks
          1. Creating the PEAR_Task_Chiara_Managedb Custom Task
          2. The Full Range of Possible Custom File Tasks
            1. validXml($pkg, $xml, &$config, $fileXml)
            2. init($xml, $fileAttributes, $lastVersion)
            3. startSession($pkg, $contents, $dest)
            4. run($tasks)
        3. Post-Installation Scripts for Ultimate Customization
            1. Components of a Post-Install Script
      4. Bundling Several Packages into a Single Archive
      5. Backwards Compatibility: Using package.xml 1.0 and 2.0
      6. Why Support Old and Crusty package.xml 1.0?
      7. Case Study: The PEAR Package
      8. PEAR_PackageFileManager
        1. Obtaining PEAR_PackageFileManager
        2. PEAR_PackageFileManager Script and the package.xml Files it Generates
        3. How PEAR_PackageFileManager Makes a Hard Life Easy
          1. Globbing Files for package.xml
          2. Managing Changelog
          3. Synchronizing package.xml Version 1.0 and package.xml Version 2.0
      9. Creating a Package for Installation with the PEAR Installer
      10. Summary
    9. 4. Clever Website Coordination Using the PEAR Installer
      1. Overview of the Problem
      2. Understanding the Problem
        1. Managing Code Breakage and Reverting to Previous Versions
        2. Managing Missing or Extraneous Files
        3. Coordinating Development with a Team of Developers
        4. Backing Up Code: Redundancy as a Necessary Precaution
      3. The Solution, Part I: All-Important Source Control
        1. Providing Redundancy and Revision History
        2. Installing CVS or Subversion
          1. Concurrent Versions System
            1. Setting Up a CVS Repository
          2. Subversion
            1. Setting Up a Subversion Repository
        3. Intelligent Source Control
          1. Maintaining Branches for Complex Versioning Support
          2. Using Tags to Mark Point Releases
      4. The Solution, Part II: Using the PEAR Installer to Update the Website
        1. Generating package.xml from the Source Control Checkout
        2. Packaging: Coordinating Release Versions with Tags and Branches
        3. Testing the Release before Uploading
        4. Upgrading the Live Server
          1. Using the pear upgrade Command
          2. The Real Beauty of Using Pear to Fix Problems
      5. Summary
    10. 5. Releasing to the World: PEAR Channels
      1. Distributing a package.xml-Based Package
      2. Distributing Packages through a Channel Server
        1. The channel.xml File
        2. channel.xml Tag Summary
        3. Obtaining Chiara_PEAR_Server
        4. Configuring the Server; Obtaining a Front End for End Users
        5. Adding a Package and Releasing Packages
        6. Installing a Public Channel Front End
      3. Distributing Pay-For-Use PHP Applications through a Channel
      4. Distributing Packages through Static tarballs for Single-Client Installations
        1. Who Needs this Feature?
        2. Differences in package.xml and Dependencies
        3. Releasing Equals Uploading
      5. Security Issues Inherent in Remote Installation
        1. How do PEAR Installer and Chiara_PEAR_Server Provide Security?
          1. Extra Security beyond what PEAR Provides
          2. Specific Security Principles Applied in Designing the PEAR Installer and Chiara_PEAR_Server
      6. Summary
    11. 6. Embedding the PEAR Installer: Designing a Custom Plug-In System
      1. Why Embed PEAR?
        1. Simplify User Choices for Installation
        2. Eliminate Chances for Error
      2. Other Plug-In Systems
        1. Bundling Plug-Ins Directly in the Source Code
        2. Subpackages PEAR Dependencies
          1. Case Study: MDB2
        3. Custom Plug-In Systems: Remote Server
          1. Case Study: Serendipity Blog's Spartacus Plug-In Manager
          2. Case Study: Seagull Framework's Embedded PEAR Installer
      3. Designing a Custom PEAR Channel-Based Plug-In System
        1. Reusing Existing Functionality
          1. PEAR Installer Infrastructure: REST and PEAR Installer Classes
            1. PEAR_Config
            2. PEAR_Dependency2
            3. PEAR_REST and PEAR_REST_10/PEAR_REST_11
            4. PEAR_Downloader and PEAR_Downloader_Package
            5. PEAR_Installer
        2. Extending REST with Custom Information
        3. Designing a Lightweight Installer Plug-In: The Code At Last
          1. MyBlog_Template_IConfig and MyBlog_Template_Config
          2. MyBlog_Template_REST
          3. MyBlog_Template_Lister
          4. MyBlog_Template_Fetcher
          5. The MyBlog Post-Install Script
          6. The Rest of the Fake MyBlog Package
          7. Improvements for the Ambitious
      4. Summary