0%

Book Description

XML, Data, Dates, Web Services, and Web APIs

About This Book

  • Maximize your productivity through the use of proven, powerful, reusable PHP components
  • In-depth coverage of a range of important PEAR packages
  • Many code examples provide a clear and practical guidance

Who This Book Is For

This book is for PHP developers who want to maximize their productivity through the use of proven, high-quality, reusable PEAR components. Some experience of working with PEAR classes will prove helpful, and developers who've used PEAR before can find something new to delight them.

What You Will Learn

Chapter 1 shows you how to access databases with the MDB2 package. You will learn:

  • Connecting to the database, and instantiate objects
  • Executing queries and fetching data
  • MDB2 SQL abstraction; sequences, replace queries, sub-select support, prepared statements
  • Using MDB2 modules
  • Extending MDB2 to provide custom fetch and result classes, iterators, and modules
  • Chapter 2 explains how to use PEAR packages to display data . It teaches you:

  • Creating powerful tables of data easily with the HTML_Table package
  • Advanced table formatting with HTML_Table_Matrix
  • Creating Excel spreadsheets dynamically with Spreadsheet_Excel_Writer
  • Adding formatting to these spreadsheets including colors, patterns, formulae and number formatting
  • Creating flexible, sortable grids of data with Structures_DataGrid
  • Adding columns to the grid, control paging, select data sources, and renderers
  • Using File_PDF to create PDF documents on the fly
  • Chapter 3 covers the usage of PEAR packages to work with XML and stresses on:

  • Creating XML documents with XML_Util, XML_Fastcreate
  • Transforming PHP objects to XML format with XML_Serializer
  • Creating Mozilla applications with XML_XUL
  • Parsing XML with XML_Parser
  • Processing XML documents to PHP objects with XML_Unserializer
  • Parsing RSS with XML_RSS
  • Chapter 4 is an extensive tutorial on working with web services and Web API's using PEAR packages. We cover the following topics:

  • Consuming web services
  • Consuming XML-RPC-based web services
  • Accessing the Google API
  • Searching blog entries with Services_Technorati
  • Accessing the Amazon web service
  • Accessing the Yahoo API
  • Offering XML-RPC-based web services
  • Offering SOAP-based web services
  • Offering REST-based services using XML_Serializer
  • Chapter 5 covers PEAR's date and time functions using the PEAR::Calendar and PEAR::Date packages such as:

  • Creating, manipulating, and comparing Date objects
  • Data_Span arithmetic
  • Handling timezones with Date_Timezone
  • Keeping track of public holidays with Date_Holiday
  • Using the Calendar class to display an HTML calendar
  • In Detail

    PEAR is the PHP Extension and Application Repository, and is a framework and distribution system for reusable, high-quality PHP components, available in the form of "packages".

    In this book, you will learn how to use a number of the most powerful PEAR packages available to boost your PHP development productivity. By focusing on these packages for key development activities, this book is an in-depth guide to getting the most from these powerful coding resources.

    Style and approach

    Packed with code examples, every topic is explained in a clear, practical way.

    Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Book Description

    XML, Data, Dates, Web Services, and Web APIs

    About This Book

    • Maximize your productivity through the use of proven, powerful, reusable PHP components
    • In-depth coverage of a range of important PEAR packages
    • Many code examples provide a clear and practical guidance

    Who This Book Is For

    This book is for PHP developers who want to maximize their productivity through the use of proven, high-quality, reusable PEAR components. Some experience of working with PEAR classes will prove helpful, and developers who've used PEAR before can find something new to delight them.

    What You Will Learn

    Chapter 1 shows you how to access databases with the MDB2 package. You will learn:

  • Connecting to the database, and instantiate objects
  • Executing queries and fetching data
  • MDB2 SQL abstraction; sequences, replace queries, sub-select support, prepared statements
  • Using MDB2 modules
  • Extending MDB2 to provide custom fetch and result classes, iterators, and modules
  • Chapter 2 explains how to use PEAR packages to display data . It teaches you:

  • Creating powerful tables of data easily with the HTML_Table package
  • Advanced table formatting with HTML_Table_Matrix
  • Creating Excel spreadsheets dynamically with Spreadsheet_Excel_Writer
  • Adding formatting to these spreadsheets including colors, patterns, formulae and number formatting
  • Creating flexible, sortable grids of data with Structures_DataGrid
  • Adding columns to the grid, control paging, select data sources, and renderers
  • Using File_PDF to create PDF documents on the fly
  • Chapter 3 covers the usage of PEAR packages to work with XML and stresses on:

  • Creating XML documents with XML_Util, XML_Fastcreate
  • Transforming PHP objects to XML format with XML_Serializer
  • Creating Mozilla applications with XML_XUL
  • Parsing XML with XML_Parser
  • Processing XML documents to PHP objects with XML_Unserializer
  • Parsing RSS with XML_RSS
  • Chapter 4 is an extensive tutorial on working with web services and Web API's using PEAR packages. We cover the following topics:

  • Consuming web services
  • Consuming XML-RPC-based web services
  • Accessing the Google API
  • Searching blog entries with Services_Technorati
  • Accessing the Amazon web service
  • Accessing the Yahoo API
  • Offering XML-RPC-based web services
  • Offering SOAP-based web services
  • Offering REST-based services using XML_Serializer
  • Chapter 5 covers PEAR's date and time functions using the PEAR::Calendar and PEAR::Date packages such as:

  • Creating, manipulating, and comparing Date objects
  • Data_Span arithmetic
  • Handling timezones with Date_Timezone
  • Keeping track of public holidays with Date_Holiday
  • Using the Calendar class to display an HTML calendar
  • In Detail

    PEAR is the PHP Extension and Application Repository, and is a framework and distribution system for reusable, high-quality PHP components, available in the form of "packages".

    In this book, you will learn how to use a number of the most powerful PEAR packages available to boost your PHP development productivity. By focusing on these packages for key development activities, this book is an in-depth guide to getting the most from these powerful coding resources.

    Style and approach

    Packed with code examples, every topic is explained in a clear, practical way.

    Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. PHP Programming with PEAR
      1. PHP Programming with PEAR
      2. Credits
      3. About the Authors
      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. MDB2
        1. A Brief History of MDB2
        2. Abstraction Layers
          1. Database Interface Abstraction
          2. SQL Abstraction
          3. Datatype Abstraction
        3. Speed Considerations
        4. MDB2 Package Design
        5. Getting Started with MDB2
          1. Installing MDB2
          2. Connecting to the Database
            1. DSN Array
            2. DSN String
          3. Instantiating an MDB2 object
          4. Options
            1. Option "persistent"
            2. Option "portability"
          5. Setting Fetch Mode
          6. Disconnecting
        6. Using MDB2
          1. A Quick Example
          2. Executing Queries
          3. Fetching Data
          4. Shortcuts for Retrieving Data
          5. query*() Shortcuts
          6. get*() Shortcuts
            1. getAssoc()
          7. Data Types
            1. Setting Data Types
            2. Setting Data Types when Fetching Results
            3. Setting Data Types for get*() and query*()
          8. Quoting Values and Identifiers
          9. Iterators
          10. Debugging
        7. MDB2 SQL Abstraction
          1. Sequences
          2. Setting Limits
          3. Replace Queries
          4. Sub-Select Support
          5. Prepared Statements
            1. Named Parameters
            2. Binding Data
            3. Execute Multiple
            4. Auto Prepare
            5. Auto Execute
          6. Transactions
        8. MDB2 Modules
          1. Manager Module
            1. Create a Database
            2. Create a Table
            3. Alter Table
            4. Constraints
            5. Indices
            6. Listings
          2. Function Module
          3. Reverse Module
        9. Extending MDB2
          1. Custom Debug Handler
          2. Custom Fetch Classes
          3. Custom Result Classes
          4. Custom Iterators
          5. Custom Modules
            1. Mymodule2
        10. MDB2_Schema
          1. Installation and Instantiation
          2. Dump a Database
          3. Switching your RDBMS
        11. Summary
      7. 2. Displaying Data
        1. HTML Tables
          1. Table Format
          2. Using HTML_Table to Create a Simple Calendar
            1. Setting Individual Cells
          3. Extended HTML_Table with HTML_Table_Matrix
        2. Excel Spreadsheets
          1. The Excel Format
          2. Our First Spreadsheet
          3. About Cells
          4. Setting Up a Page for Printing
          5. Adding some Formatting
          6. About Colors
          7. Pattern Fill
          8. Number Formatting
          9. Adding Formulas
          10. Multiple Worksheets, Borders, and Images
          11. Other ways to create Spreadsheets
            1. CSV
            2. The Content-Type Trick
            3. Generating Excel 2003 Files
            4. Creating Spreadsheets using PEAR_OpenDocument
        3. DataGrids
          1. DataSources
          2. Renderers
          3. A Simple DataGrid
          4. Paging the Results
          5. Using a DataSource
          6. Using a Renderer
          7. Making it Pretty
          8. Extending DataGrid
          9. Adding Columns
        4. Generating PDF Files
          1. Colors
          2. Fonts
          3. Cells
          4. Creating Headers and Footers
        5. Summary
      8. 3. Working with XML
        1. PEAR Packages for Working with XML
        2. Creating XML Documents
          1. Creating a Record Label from Objects
          2. Creating XML Documents with XML_Util
            1. Additional Features
          3. Creating XML Documents with XML_FastCreate
            1. Interlude: Overloading in PHP5
            2. Back to XML
            3. Creating the XML Document
            4. Pitfalls in XML_FastCreate
          4. Creating XML Documents with XML_Serializer
            1. XML_Serializer Options
            2. Adding Attributes
            3. Treating Indexed Arrays
            4. Creating the XML Document from the Object Tree
            5. Putting Objects to Sleep
            6. What's your Type?
          5. Creating Mozilla Applications with XML_XUL
            1. XUL Documents
            2. Creating XUL Documents with XML_XUL
            3. Creating a Tab Box
        3. Processing XML Documents
          1. Parsing XML with XML_Parser
            1. Enter XML_Parser
            2. Implementing the Callbacks
            3. Adding Logic to the Callbacks
            4. Accessing the Configuration Options
            5. Avoiding Inheritance
            6. Additional XML_Parser Features
          2. Processing XML with XML_Unserializer
            1. Parsing Attributes
            2. Mapping XML to Objects
            3. Unserializing the Record Labels
            4. Additional Features
            5. XML_Parser vs. XML_Unserializer
          3. Parsing RSS with XML_RSS
        4. Summary
      9. 4. Web Services
        1. Consuming Web Services
          1. Consuming XML-RPC-Based Web Services
          2. Accessing the Google API
          3. Consuming REST-Based Web Services
            1. Searching Blog Entries with Services_Technorati
              1. The Technorati Cosmos
            2. Accessing the Amazon Web Service
              1. Setting up an Amazon Account
              2. Searching the Amazon.com Website
              3. Controlling the Response
              4. Additional Services
          4. Consuming Custom REST Web Services
            1. How REST Services Work
            2. Accessing the Yahoo API
        2. Offering a Web Service
          1. Offering XML-RPC-Based Web Services
            1. Error Management
          2. Offering SOAP-Based Web Services
            1. Error Management
          3. Offering REST-Based Services using XML_Serializer
            1. Our Own REST Service
        3. Summary
      10. 5. Working with Dates
        1. Working with the Date Package
          1. Date
            1. Creating a Date Object
            2. Querying Information
            3. Manipulating Date Objects
            4. Comparing Dates
            5. Formatted Output
            6. Creating a Date_Span Object
            7. Manipulating Date_Span Objects
            8. Timespan Conversions
            9. Comparisons
            10. Formatted Output
            11. Date Objects and Timespans
          2. Dealing with Timezones using Date_Timezone
            1. Creating a Date_Timezone object
            2. Querying Information about a Timezone
            3. Comparing Timezone Objects
            4. Date Objects and Timezones
          3. Conclusion on the PEAR::Date Package
        2. Date_Holidays
          1. Instantiating a Driver
          2. Identifying Holidays
          3. The Date_Holidays_Holiday Class
          4. Calculating Holidays
            1. Getting Holiday Information
            2. Filtering Results
            3. Combining Holiday Drivers
          5. Is Today a Holiday?
          6. Multi-Lingual Translations
            1. Adding a Language File
            2. Getting Localized Output
          7. Conclusion on Date_Holidays
        3. Working with the Calendar Package
          1. Introduction to Basic Classes and Concepts
          2. Object Creation
            1. Querying Information
            2. Building and Fetching
            3. Make a Selection
          3. Validating Calendar Date Objects
            1. Validation Versus Adjustment
            2. Dealing with Validation Errors
          4. Adjusting the Standard Classes' Behavior
            1. What are Decorators?
            2. The Common Decorator Base Class
            3. Bundled Decorators
          5. Generating Graphical Output
            1. Navigable Tabular Calendars
        4. Summary
    54.175.120.161