PHPackages                             slightlydiff/yii2-xero - 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. slightlydiff/yii2-xero

ActiveYii2-extension[API Development](/categories/api)

slightlydiff/yii2-xero
======================

An extension for using the Xero API from within Yii2

v1.0.2(9y ago)115.4k4[3 issues](https://github.com/slightlydiff/yii2-xero/issues)Apache-2.0PHPPHP &gt;=5.5

Since Aug 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/slightlydiff/yii2-xero)[ Packagist](https://packagist.org/packages/slightlydiff/yii2-xero)[ RSS](/packages/slightlydiff-yii2-xero/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Xero API for Yii2
=================

[](#xero-api-for-yii2)

An extension for using the Xero API from within Yii2.

This extension is based on Xero's XeroOAuth-PHP code at

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist slightlydiff/yii2-xero "*"

```

or add

```
"slightlydiff/yii2-xero": "*"

```

to the require section of your `composer.json` file.

Configuration
-------------

[](#configuration)

Add the following to your application conmfiguration file:

```
        'xeroApi' => [
            'class' => 'slightlydiff\xero\XeroApi',
            'rsa_public_key' => '@app/config/certs/xero_publickey.cer',
            'rsa_private_key' => '@app/config/certs/xero_privatekey.pem',
            'consumer_key' => 'yourconsumerkey',
            'shared_secret' => 'yoursharedsecret',
            'useragent' => 'XeroOAuth-PHP'
        ],
```

modifying the above for your own Xero consumer key, shared secret and the path to you public / private key pair.

Usage
-----

[](#usage)

> For a GET request:
>
> - The first parameter is the only required parameter and must be 'GET', 'POST', 'PUT' or 'DELETE'
> - The second parameter can be FALSE or a string ID if you want to get a single record by ID
> - The third parameter can be a date/time, in any format, if you want to fetch all records modified since that date
> - The fourth parameter can be an array of filters as described at . This allows you to filter the query and order the returned data.
>
> All parameters are optional except the first. If not parameters are passed then all records of the requested type will be returned
>
> For a POST or PUT request:
>
> - The first parameter must be the method, as above, and the second param must be a multidimensional array of the data being passed as in the examples below.

To create a contact see  for the format and apply as follows:

```
$new_contact = array(
    array(
        "Name" => "Joe Bloggs",
        "FirstName" => "Joe",
        "LastName" => "Bloggs",
        "Addresses" => array(
            "Address" => array(
                array(
                    "AddressType" => "POSTAL",
                    "AddressLine1" => "123 Anystreet",
                    "City" => "Anytown",
                    "PostalCode" => "1234"
                ),
                array(
                    "AddressType" => "STREET",
                    "AddressLine1" => "123 Anystreet",
                    "City" => "Anytown",
                    "PostalCode" => "1234"
                )
            )
        )
    )
);
$result = $xero->Contacts('POST', $new_invoice);
```

To create a invoice or credit note see  for the format and apply as follows:

```
$new_invoice = array(
    array(
        "Type"=>"ACCREC",
        "Contact" => array(
            "ContactID" => "[contact id]"
        ),
        "Date" => "2016-08-01",
        "DueDate" => "2016-08-30",
        "Status" => "SUBMITTED",
        "LineAmountTypes" => "Exclusive",
        "LineItems"=> array(
            "LineItem" => array(
                array(
                    "Description" => "Some product description",
                    "Quantity" => "1.0000",
                    "UnitAmount" => "123.00",
                    "AccountCode" => "200"
                )
            )
        )
    )
);
$result = $xero->Invoices('POST', $new_invoice);
```

To create a payment see  for the format and apply as follows:

```
$new_payment = array(
    array(
        "Invoice" => array(
            "InvoiceNumber" => "INV-1234"
        ),
        "Account" => array(
            "Code" => "[account code]"
        ),
        "Date" => "2016-08-30",
        "Amount"=>"123.00",
    )
);
$result = $xero->Payments('POST', $new_payment);
```

To get details of an account with the name "Joe Bloggs"

```
$result = $xero->Accounts('GET', false, false, array("Name"=>"Joe Bloggs") );
```

See  for a list of all parameters.

To get details of all contacts

```
$result = $xero->Contacts;
```

To get details of all contacts modified in the last 24 hours

```
$result = $xero->Contacts('GET', false, gmdate("M d Y H:i:s", (time() - (1 * 24 * 60 * 60))), false);
```

To get details of a contact by ID

```
$result = $xero->Contacts('GET', 'contact id here', false, false);
```

To get details of all contacts whos name contains "Bloggs" and order the results by Name

```
$result = $xero->Contacts('GET', false, false, ['where' => 'Name.Contains("Bloggs")', 'order' => 'Name DESC']);
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 89.3% 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 ~10 days

Total

3

Last Release

3528d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1666768?v=4)[Stephen Smith](/maintainers/slightlydiff)[@slightlydiff](https://github.com/slightlydiff)

---

Top Contributors

[![ronanq](https://avatars.githubusercontent.com/u/655394?v=4)](https://github.com/ronanq "ronanq (167 commits)")[![elliotchance](https://avatars.githubusercontent.com/u/927418?v=4)](https://github.com/elliotchance "elliotchance (6 commits)")[![torohill](https://avatars.githubusercontent.com/u/281118?v=4)](https://github.com/torohill "torohill (3 commits)")[![lloydhazlett](https://avatars.githubusercontent.com/u/366728?v=4)](https://github.com/lloydhazlett "lloydhazlett (3 commits)")[![mradcliffe](https://avatars.githubusercontent.com/u/328497?v=4)](https://github.com/mradcliffe "mradcliffe (3 commits)")[![tomcastleman](https://avatars.githubusercontent.com/u/1532660?v=4)](https://github.com/tomcastleman "tomcastleman (2 commits)")[![MattHealy](https://avatars.githubusercontent.com/u/411449?v=4)](https://github.com/MattHealy "MattHealy (1 commits)")[![IanSimpson](https://avatars.githubusercontent.com/u/782493?v=4)](https://github.com/IanSimpson "IanSimpson (1 commits)")[![drewbroadley](https://avatars.githubusercontent.com/u/1505816?v=4)](https://github.com/drewbroadley "drewbroadley (1 commits)")

---

Tags

apiyii2extensionxero

### Embed Badge

![Health badge](/badges/slightlydiff-yii2-xero/health.svg)

```
[![Health](https://phpackages.com/badges/slightlydiff-yii2-xero/health.svg)](https://phpackages.com/packages/slightlydiff-yii2-xero)
```

###  Alternatives

[dotzero/yii2-amocrm

Расширение для Yii Framework 2 реализующее клиент для работы с API amoCRM

1639.7k](/packages/dotzero-yii2-amocrm)[mikemadisonweb/yii2-elasticsearch

Yii2 extension for integration with Elasticsearch version 5.0 and above.

163.9k](/packages/mikemadisonweb-yii2-elasticsearch)[apexwire/yii2-restclient

Tools to use API as ActiveRecord for Yii2

143.5k](/packages/apexwire-yii2-restclient)

PHPackages © 2026

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