CodeIgniter + QuickBooks Online PHP SDK Integration
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

CodeIgniter - Quickbooks Online SDK integration

The purpose of this project is to show an example integration between CodeIgniter Framework and the QuickBooks PHP SDK for connecting QuickBooks Online service. At the same time, this integration might provide some useful insights to CodeIgniter's users about how to take advantage of Composer packages avoiding reinventing the wheel. For this later purpose, I'll be using PHP League's OAuth2 client library instead of the Oauth2 library provided by Intuit itself on another repository.


I've added a Quickbooks.php library which should greatly streamline your interactions with QuickBooks Online. It is an important addition to this project. You can see it in action in the new QB_tests.php controller.

Getting Started

The scenario/use case is the following:

  1. The user visits a section of the website where a "Connect" button is displayed.

2. The user clicks the button, a new window pops up asking him/her to connect to Quickbooks and authorize the application.

3. After logging in and having authorized the application, the page showing the button will now display a new confirmation message indicating that the authorization was successful.


For the sake of simplicity, this example assumes that you:

  • ...are using a fresh copy of CodeIgniter >=3.1.9 (that doesn't mean that you can not use these files with an existing project. Just try to catch up with everything on a fresh installation, then adapt it to your needs).
  • ...know how to use Composer and have it configured on your workstation.
  • ...have correctly configured your config.php file to point to your CodeIgniter's installation directory.

After installing, performing further tweaking in order to fit your needs should be an easy task.


  1. Copy the following lines in the "require" section of your CodeIgniter's composer.json file:
"quickbooks/v3-php-sdk": ">=4.0.1",
"league/oauth2-client": "^2.3"

The final result should look like the following:

  "require": {
    "php": ">=5.3.7",
    "quickbooks/v3-php-sdk": ">=4.0.1",
    "league/oauth2-client": "^2.3"

Run composer update command afterwards.

  1. Open the CodeIgniter's config file (config.php) and locate the line dedicated to configure Composer autoload. Set the value to:

The final result should look like the following:

$config['composer_autoload'] = 'vendor/autoload.php';
  1. Make sure to autoload the following resources through CodeIgniter's native config/autoload.php file (it will not conflict with Composer packages):

Helpers: url, security Libraries: session Configs: quickbooks

The final result should look like the following:

$autoload['helper'] = array('url','security');
$autoload['libraries'] = array('session');
$autoload['config'] = array('quickbooks');
  1. Copy the application/config/quickbooks.php file into your config/ directory and modify the values according to your Intuit App details.

  2. Copy the file application/controllers/Qb_oauth_endpoint.php file into your controllers/ directory.

  3. Copy the file application/controllers/Qb_tests.php into your controllers/ directory.

  4. Copy the file application/views/welcome_message.php into your views/ directory (this is just a modified version of the native welcome_message.php that comes with CodeIgniter. You'll notice a tiny modification where some Javascript lines were added in order to provide an example of the authorization workflow).

  5. Copy the file application/views/qb_tests.php into your views/ directory.

  6. Copy the file application/helpers/security_helper.php into your helpers/ directory.

Running the tests

Point your browser to your CodeIgniter's installation (E.g. http://localhost/ciqb-integrator/). You should see a slightly modified version of the welcome_message.php template which includes a "Connect to QuickBooks" button.

Click on the button. It should open a popup window asking authenticate yourself to Quickbooks, and authorizing the application (connecting it) afterwards.

Once the application is connected, the popup closes and the page is refreshed showing a "Successfully connected..." message.

You can now point your browser to the Qb_tests controller (E.g. http://localhost/ciqb-integrator/index.php/qb_tests) and look some examples in action.



This project is licensed under the MIT License - see the LICENSE file for details


  • Intuit, for providing such an elegant PHP SDK.
  • The League of Extraordinary Packages, for making the world a better place with their outstanding packages.