PHPackages                             rangka/quickbooks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rangka/quickbooks

AbandonedArchivedLibrary[API Development](/categories/api)

rangka/quickbooks
=================

Quickbooks' PHP Client

v2.0.1(7y ago)921.8k10[1 issues](https://github.com/rangka/quickbooks/issues)MITPHPPHP &gt;=5.5

Since Mar 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/rangka/quickbooks)[ Packagist](https://packagist.org/packages/rangka/quickbooks)[ Docs](http://rangka.my/quickbooks)[ RSS](/packages/rangka-quickbooks/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (10)Dependencies (4)Versions (16)Used By (0)

Quickbooks
==========

[](#quickbooks)

PHP Library for connecting to QuickBooks.

> Note: This was done with an AU account. There are differences between regions of Quickbooks Account. If you are using a different region's account and encounter any issue, please make a report of it.

Installation
============

[](#installation)

Install it using composer.

```
composer require rangka/quickbooks

```

Configuring
===========

[](#configuring)

To start using this library, you must create an app in the [Developer's Dashboard](https://developer.intuit.com/v2/ui#/app/dashboard) and obtain the client ID and secret.

Add this to the beginning of your app.

```
\Rangka\Quickbooks\Client::configure([
    'client_id'     => 'CLIENT_ID',
    'client_secret' => 'CLIENT_SECRET',
    'sandbox'       => true, // or `false`
    'oauth'         => $_SESSION['OAUTH'],
    'realm_id'      => $_SESSION['REALM_ID'],
]);

```

- `SANDBOX` - Use `true` if this is a development environment. Leave it empty or `false` for production.
- `OAUTH` - Represents the entire array returned after requesting for access token. This will be `null` when you first start out but must be filled after successfully obtaining an access token.
- `realm_id` - This is your company's ID and is required when making API calls. You will obtain this ID on the 2nd step (after user authorizes on Quickbook) of **Connecting to Quickbooks**.

Connecting to Quickbooks
========================

[](#connecting-to-quickbooks)

Quickbooks uses OAuth2 in order to establish an authenticated connection to it. This documentation will not delve too much detail into it and instead will just lay out what you need. Go through the documentation to find out more.

**1. Authorization**

Redirect user to Quickbooks' login page. Get the URL via;

```
$connector = new Rangka\Quickbooks\Connect();
$url = $connector->getAuthorizationURL();

```

**2. Prepare a redirection page**

```
$connector = new \Rangka\Quickbooks\Connect();

// Provide it with values from query parameters.
$result = $connector->requestToken($_GET);

// Save $result somewhere. We will use it in Client::configure().
$_SESSION['oauth'] = $result;

// Realm ID is provided on query parameter so make sure to save it as well.
$_SESSION['realm_id'] = $_GET['realmId'];

```

Reconnect
=========

[](#reconnect)

OAuth have a very limited usage period (usually about 1 hour). In order to refresh the token;

```
$connector = new \Rangka\Quickbooks\Connect();

if ($connector->hasExpired()) {
    // Make sure to save the result. We will use it in Client::configure().
    $_SESSION['oauth'] = $connector->refreshToken();
}

```

Disconnect
==========

[](#disconnect)

Simply remove all of the Configuration values from your storage.

Usage
=====

[](#usage)

#### Read

[](#read)

To read a resource, initialize its service and call `load($id)` on it. Take note not all Service have read capability. Check QB's documentation to know which one does and which one does not;  .

```
$service = new \Rangka\Quickbooks\Services\Invoice;
$response = $service->load($id);

```

Response will be in `stdClass` object.

#### Delete

[](#delete)

Deleting a resource is basically the same as loading except calling on `delete($id)` instead.

```
$service = new \Rangka\Quickbooks\Services\Invoice;
$response = $service->delete($id);

```

#### Create

[](#create)

In order to create, you will need to obtain a Builder for the entity you wish for. You can get the Builder instance from its Service. Example given is for Invoice;

```
$service = new \Rangka\Quickbooks\Services\Invoice;
$builder = $service->getBuilder();

```

Any property can be added by calling `set{$propertyName}`. For example setting the amount;

```
$builder->setAmount(100);

```

Nested value have two ways to be added. Either straight up arrays via its top-level property or using various helper methods within the Builder.

Straight up array;

```
$builder->setCustomerRef([
    'value' => 1
]);

```

Helper methods;

```
$builder->setCustomer(1);

```

Once you've built up your data, just call `create()`.

```
$invoice = $builder->create();

```

Upon doing so you Invoice will be created and your Invoice data object will be retured.

Putting it all together;

```
$service = new \Rangka\Quickbooks\Services\Invoice;
$builder = $service->getBuilder();
$builder->setAmount(100)
        ->setCustomer(1);

$invoice = $builder->create();

```

Note 1: Above example is a non-working solution. Please check Quickbooks' documentation on what are the required fields for each Entity.

Note 2: Builder methods can be chained, except for `create()` which will return the created object.

#### Update

[](#update)

Updating is exactly the same as Create however you will need to set a SyncToken first `setSyncToken()` and call `update()` instead.

```
$service = new \Rangka\Quickbooks\Services\Invoice;
$builder = $service->getBuilder();
$builder->setAmount(100)
        ->setCustomer(1)
        ->setSyncToken($syncToken);

$invoice = $builder->update();

```

An updated object will be returned by `update()`.

#### Attachment

[](#attachment)

```
$id = 566;                         // Required
$files = [
    [
        'path' => '/path/to/file', // Required
        'type' => 'image/png'      // Optional
        'name' => 'filename.png'   // Optional
    ]
];
$includeOnSend = true;             // Optional

$service = new \Rangka\Quickbooks\Services\Invoice;
$service->attach($id, $files, $includeOnSend);

```

`$files` is an array of associative array. Add more of the associative array to upload more files at the same time.

Note: Not all Entities can have attachments. Currently supported Entity with Attachments is Invoice, Vendor, VendorCredit, Purchase, PurchaseOrder, Transfer, JournalEntry, Deposit, CreditMemo, Estimate, RefundReceipt, SalesReceipt, Bill, Customer and Payment.

Entity-specific Usage
=====================

[](#entity-specific-usage)

Certain entities have usages beyond the normal CRUD operation.

Attachable
----------

[](#attachable)

#### Uploading File

[](#uploading-file)

```
$service = new \Rangka\Quickbooks\Services\Attachable;
$builder = $service->getBuilder();

// This is required
$file = [
    'path' => '/path/to/file', // Required
    'type' => 'image/png'      // Optional
    'name' => 'filename.png'   // Optional
];

// This is optional
$entities = [
    [
        'entity'        => 'Invoice',
        'id'            => 566,
        'includeOnSend' => true,
    ]
];

$builder->addFile($file, $entities);
$response = $builder->upload();

```

You are allowed to specify multiple Entities per Attachable.

Response upon upload is an array of Attachable objects.

Note: While Attachable can be used directly, its generally not recommended if you wish to upload a single file to a specific entity. Use each respective Services to upload files. Only use this if you wish to upload and link to several entities at once.

Invoice
-------

[](#invoice)

#### Send Email

[](#send-email)

```
$service = new \Rangka\Quickbooks\Services\Invoice;
$service->email($invoiceID, $email); // Email is optional

```

#### Download PDF

[](#download-pdf)

```
$service = new \Rangka\Quickbooks\Services\Invoice;
$service->downloadPdf($invoiceID);

```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 96.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~86 days

Recently: every ~98 days

Total

14

Last Release

2629d ago

Major Versions

v0.1.9 → v1.x-dev2018-03-22

v1.0 → v2.02019-04-16

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2367607?v=4)[Khairul Ashraff](/maintainers/khairulashraff)[@khairulashraff](https://github.com/khairulashraff)

---

Top Contributors

[![khairulashraff](https://avatars.githubusercontent.com/u/2367607?v=4)](https://github.com/khairulashraff "khairulashraff (98 commits)")[![Gnilya](https://avatars.githubusercontent.com/u/2853725?v=4)](https://github.com/Gnilya "Gnilya (1 commits)")[![jnstr](https://avatars.githubusercontent.com/u/4415223?v=4)](https://github.com/jnstr "jnstr (1 commits)")[![jthomaschewski](https://avatars.githubusercontent.com/u/682607?v=4)](https://github.com/jthomaschewski "jthomaschewski (1 commits)")[![sznowak](https://avatars.githubusercontent.com/u/3908735?v=4)](https://github.com/sznowak "sznowak (1 commits)")

---

Tags

phpquickbooks

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rangka-quickbooks/health.svg)

```
[![Health](https://phpackages.com/badges/rangka-quickbooks/health.svg)](https://phpackages.com/packages/rangka-quickbooks)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M398](/packages/drupal-core-recommended)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.7k371.6k6](/packages/theodo-group-llphant)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
