Skip to main content
This library has its own tag, so this Q should have it too, for easier search.
Link

Stack.PHP - Powerful and Extensive Library for Accessing the Stack Exchange API - Including Full Support for v2.0.  

Update for 0.5 beta 1.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107

Stack.PHP - Completely Rewritten from the Ground Up [Now with supportPowerful and Extensive Library for v2.0 ofAccessing the Stack Exchange API - including OAuth 2Including Full Support for v2.0 methods!].

##API v2.0 Update I am pleased to announce that Stack.PHP has implemented some of the new changes introduced in version 2.0 of the API. You can now begin developing PHP applications that use v2.0 of the API.

These changes are still in beta and things are not expected to work perfectly yet. I have finished implementing all of the API methods. OAuth support has been completed and tested.

Definitely be sure to check out the new Stack.PHP website here:
http://stackphp.quickmediasolutions.com

Your feedback is appreciated at this time - I'm sure there are many bugs to be uncovered and the sooner they are found, the better.


Don't know where to start?

Stack.PHP is a PHP library for accessing and retrieving information from the Stack Exchange APIBegin by checking out the Stack.PHP website.
Then Headhead over here for a quick tutorial on setting up and using Stack.PHP.

  • A flexible caching system. Stack.PHP is designed to use as few API requests as possible. The library comes with two classes that can be set to automatically cache the responses of all API requests made: an SQL cache class (compatible with all database systems that have a PDO driver) and a filestore class (which stores the cached data on the filesystem). If none of the classes meets your needs, you can easily implement the CacheBase class in one of your own classes and customize it to your heart's content.
  • An intuitive pagination class. All requests (with perhaps one or two exceptions) return an instance of a Response or PagedResponse object. This object provides an easy means of stepping through the objects returned. In the case of a PagedRequest object, additional pages of data are automatically fetched as needed as you step through the data returned. This code that uses a Response and PagedResponse object is basically identical.
  • Fully tested. The archives available for download and the code on Launchpad come with a tests folder. This folder contains an exhaustive test suite for Stack.PHP that runs through every API route, comparing the responses against expected output. These tests also make sure the utility code (such as the cache management code) is functioning as expected.
  • Fully documented. The entire codebase makes use of Doxygen comments throughout, making it easy to quickly generate HTML pages that describe in detail what each of the methods, enumerations, etc. do and any potential side effects you might encounter. The documentation can be found in the doc folder in the archives.
  • Easy to pick up and learn. To commemorate the first release in the 0.4 series, I have written a 7 page document on Google Docs which guides you through the basics of using the library.
  • Complete support for authentication. Stack.PHP supports the API's OAuth 2.0 methods out-of-the-box and without any third-party libraries. Everything just works - and you can immediately get a feel for how authentication works by dropping an API key / ID into one of the examples and trying it out. Both the implicit and explicit authentication flows are supported.
  • An organized exception class. Exceptions can come from all over the place in Stack.PHP (from cURL, from the cache classes, etc.), so it made sense to create a flexible exception class that captured the relevant information. You can see how this works by examining the test suite that is included with the library.
  • OutputHelper class to save you from writing HTML / CSS / JS. When designing a web application that uses Stack.PHP, you will find yourself writing certain snippets of code again and again. Stack.PHP saves you from having to do this by offering a simple OutputHelper class that generates HTML / CSS / JS code for you. Do you want to generate a <select> containing all Stack Exchange sites without their corresponding Metas? No problem - this can be solved with one line of code.
  • A full slate of real-world examples. It's one thing to know how to use Stack.PHP in theory. It's another thing to understand what typical and proper usage of the library looks like. That's why the library ships with a number of examples that demonstrate best practices and usage patterns - examples that range from really simple to very complex.

The latest beta release is 0.45 beta 1 and can be downloaded here:
http://launchpad.net/stackphp/0.5/0.5beta1/+download/stackphp-0.5beta1-source.tar.gz

The previous stable release can be found here:
http://launchpad.net/stackphp/0.4/0.4/+download/stackphp_source_0.4.zip

The previous stable version is available hereEven older versions:
http://launchpad.net/stackphp/0.3/stackphp0.3/+download/stackphp_0.3.tar.gz

Even older versions:
http://launchpad.net/stackphp/0.2/stackphp0.2/+download/stackphp_0.2.tar.gz
http://launchpad.net/stackphp/0.1/stackphp0.1/+download/stackphp_0.1.tar.gz

PHP 5.2 or higher is required for most of the library. The SQLite driver for the cache class has a bug that prevents it from working in PHP 5.2, however.

Stack.PHP - Completely Rewritten from the Ground Up [Now with support for v2.0 of the API - including OAuth 2.0 methods!]

##API v2.0 Update I am pleased to announce that Stack.PHP has implemented some of the new changes introduced in version 2.0 of the API. You can now begin developing PHP applications that use v2.0 of the API.

These changes are still in beta and things are not expected to work perfectly yet. I have finished implementing all of the API methods. OAuth support has been completed and tested.

Definitely be sure to check out the new Stack.PHP website here:
http://stackphp.quickmediasolutions.com

Your feedback is appreciated at this time - I'm sure there are many bugs to be uncovered and the sooner they are found, the better.


Don't know where to start?

Stack.PHP is a PHP library for accessing and retrieving information from the Stack Exchange API.
Head over here for a quick tutorial on setting up and using Stack.PHP.

  • A flexible caching system. Stack.PHP is designed to use as few API requests as possible. The library comes with two classes that can be set to automatically cache the responses of all API requests made: an SQL cache class (compatible with all database systems that have a PDO driver) and a filestore class (which stores the cached data on the filesystem). If none of the classes meets your needs, you can easily implement the CacheBase class in one of your own classes and customize it to your heart's content.
  • An intuitive pagination class. All requests (with perhaps one or two exceptions) return an instance of a Response or PagedResponse object. This object provides an easy means of stepping through the objects returned. In the case of a PagedRequest object, additional pages of data are automatically fetched as needed as you step through the data returned. This code that uses a Response and PagedResponse object is basically identical.
  • Fully tested. The archives available for download and the code on Launchpad come with a tests folder. This folder contains an exhaustive test suite for Stack.PHP that runs through every API route, comparing the responses against expected output. These tests also make sure the utility code (such as the cache management code) is functioning as expected.
  • Fully documented. The entire codebase makes use of Doxygen comments throughout, making it easy to quickly generate HTML pages that describe in detail what each of the methods, enumerations, etc. do and any potential side effects you might encounter. The documentation can be found in the doc folder in the archives.
  • Easy to pick up and learn. To commemorate the first release in the 0.4 series, I have written a 7 page document on Google Docs which guides you through the basics of using the library.
  • An organized exception class. Exceptions can come from all over the place in Stack.PHP (from cURL, from the cache classes, etc.), so it made sense to create a flexible exception class that captured the relevant information. You can see how this works by examining the test suite that is included with the library.
  • OutputHelper class to save you from writing HTML / CSS / JS. When designing a web application that uses Stack.PHP, you will find yourself writing certain snippets of code again and again. Stack.PHP saves you from having to do this by offering a simple OutputHelper class that generates HTML / CSS / JS code for you. Do you want to generate a <select> containing all Stack Exchange sites without their corresponding Metas? No problem - this can be solved with one line of code.

The latest release is 0.4 and can be found here:
http://launchpad.net/stackphp/0.4/0.4/+download/stackphp_source_0.4.zip

The previous stable version is available here:
http://launchpad.net/stackphp/0.3/stackphp0.3/+download/stackphp_0.3.tar.gz

Even older versions:
http://launchpad.net/stackphp/0.2/stackphp0.2/+download/stackphp_0.2.tar.gz
http://launchpad.net/stackphp/0.1/stackphp0.1/+download/stackphp_0.1.tar.gz

PHP 5.2 or higher.

Stack.PHP - Powerful and Extensive Library for Accessing the Stack Exchange API - Including Full Support for v2.0.

Don't know where to start?

Begin by checking out the Stack.PHP website.
Then head over here for a quick tutorial on setting up and using Stack.PHP.

  • A flexible caching system. Stack.PHP is designed to use as few API requests as possible. The library comes with two classes that can be set to automatically cache the responses of all API requests made: an SQL cache class (compatible with all database systems that have a PDO driver) and a filestore class (which stores the cached data on the filesystem). If none of the classes meets your needs, you can easily implement the CacheBase class in one of your own classes and customize it to your heart's content.
  • An intuitive pagination class. All requests (with perhaps one or two exceptions) return an instance of a Response or PagedResponse object. This object provides an easy means of stepping through the objects returned. In the case of a PagedRequest object, additional pages of data are automatically fetched as needed as you step through the data returned. This code that uses a Response and PagedResponse object is basically identical.
  • Fully tested. The archives available for download and the code on Launchpad come with a tests folder. This folder contains an exhaustive test suite for Stack.PHP that runs through every API route, comparing the responses against expected output. These tests also make sure the utility code (such as the cache management code) is functioning as expected.
  • Fully documented. The entire codebase makes use of Doxygen comments throughout, making it easy to quickly generate HTML pages that describe in detail what each of the methods, enumerations, etc. do and any potential side effects you might encounter. The documentation can be found in the doc folder in the archives.
  • Easy to pick up and learn. To commemorate the first release in the 0.4 series, I have written a 7 page document on Google Docs which guides you through the basics of using the library.
  • Complete support for authentication. Stack.PHP supports the API's OAuth 2.0 methods out-of-the-box and without any third-party libraries. Everything just works - and you can immediately get a feel for how authentication works by dropping an API key / ID into one of the examples and trying it out. Both the implicit and explicit authentication flows are supported.
  • An organized exception class. Exceptions can come from all over the place in Stack.PHP (from cURL, from the cache classes, etc.), so it made sense to create a flexible exception class that captured the relevant information. You can see how this works by examining the test suite that is included with the library.
  • OutputHelper class to save you from writing HTML / CSS / JS. When designing a web application that uses Stack.PHP, you will find yourself writing certain snippets of code again and again. Stack.PHP saves you from having to do this by offering a simple OutputHelper class that generates HTML / CSS / JS code for you. Do you want to generate a <select> containing all Stack Exchange sites without their corresponding Metas? No problem - this can be solved with one line of code.
  • A full slate of real-world examples. It's one thing to know how to use Stack.PHP in theory. It's another thing to understand what typical and proper usage of the library looks like. That's why the library ships with a number of examples that demonstrate best practices and usage patterns - examples that range from really simple to very complex.

The latest beta release is 0.5 beta 1 and can be downloaded here:
http://launchpad.net/stackphp/0.5/0.5beta1/+download/stackphp-0.5beta1-source.tar.gz

The previous stable release can be found here:
http://launchpad.net/stackphp/0.4/0.4/+download/stackphp_source_0.4.zip

Even older versions:
http://launchpad.net/stackphp/0.3/stackphp0.3/+download/stackphp_0.3.tar.gz
http://launchpad.net/stackphp/0.2/stackphp0.2/+download/stackphp_0.2.tar.gz
http://launchpad.net/stackphp/0.1/stackphp0.1/+download/stackphp_0.1.tar.gz

PHP 5.2 or higher is required for most of the library. The SQLite driver for the cache class has a bug that prevents it from working in PHP 5.2, however.

deleted 178 characters in body; edited tags
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107

##API v2.0 Update I am pleased to announce that Stack.PHP has implemented some of the new changes introduced in version 2.0 of the API. You can now begin developing PHP applications that use v2.0 of the API (note: you will need to be a part of the private beta to use Stack.PHP - you will need to provide Stack.PHP with an API key).

These changes are still in beta and things are not expected to work perfectly yet. I have finished implementing all of the API methods (except for /access-token/* and /filter/{filters}/read). OAuth support has been completed and tested.

Definitely be sure to check out the examplesnew Stack.PHP website here:
http://stackphp.quickmediasolutions.com/examples/http://stackphp.quickmediasolutions.com

Your feedback is appreciated at this time - I'm sure there are many bugs to be uncovered and the sooner they are found, the better.

##API v2.0 Update I am pleased to announce that Stack.PHP has implemented some of the new changes introduced in version 2.0 of the API. You can now begin developing applications that use v2.0 of the API (note: you will need to be a part of the private beta to use Stack.PHP - you will need to provide Stack.PHP with an API key).

These changes are still in beta and things are not expected to work perfectly yet. I have finished implementing all of the API methods (except for /access-token/* and /filter/{filters}/read). OAuth support has been completed and tested.

Definitely be sure to check out the examples here:
http://stackphp.quickmediasolutions.com/examples/

Your feedback is appreciated at this time - I'm sure there are many bugs to be uncovered and the sooner they are found, the better.

##API v2.0 Update I am pleased to announce that Stack.PHP has implemented some of the new changes introduced in version 2.0 of the API. You can now begin developing PHP applications that use v2.0 of the API.

These changes are still in beta and things are not expected to work perfectly yet. I have finished implementing all of the API methods. OAuth support has been completed and tested.

Definitely be sure to check out the new Stack.PHP website here:
http://stackphp.quickmediasolutions.com

Your feedback is appreciated at this time - I'm sure there are many bugs to be uncovered and the sooner they are found, the better.

Update for completion of methods.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Updated for version 0.4 and the new 2.0 API changes.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Updated for beta2.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Completely rewrote library from scratch.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Documentation update.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Updated with new changes.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Added v1.1 Support.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
edited title
Link
Jeff Atwood
  • 960
  • 1
  • 12
  • 18
Loading
Added new meta-data to page.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Added doc. blurb.
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Added StackMail
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Fixed typo
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Added download link
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Brought up to date
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
added 227 characters in body; edited tags
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading
Source Link
Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107
Loading