PHPackages                             macsidigital/laravel-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. macsidigital/laravel-xero

ActiveLibrary[API Development](/categories/api)

macsidigital/laravel-xero
=========================

Xero Laravel package

1.1.0(6y ago)1810MITPHPPHP ^7.2|^7.3

Since Jun 25Pushed 5y ago2 watchersCompare

[ Source](https://github.com/MacsiDigital/laravel-xero)[ Packagist](https://packagist.org/packages/macsidigital/laravel-xero)[ Docs](https://github.com/macsidigital/laravel-xero)[ RSS](/packages/macsidigital-laravel-xero/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (5)Versions (23)Used By (0)

Laravel package for Xero Accounting
===================================

[](#laravel-package-for-xero-accounting)

[![Latest Version on Packagist](https://camo.githubusercontent.com/91e895dd3d3bc29ec492683d3cc97a9559978158263c15e044a470e525b0ce33/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616373696469676974616c2f6c61726176656c2d7865726f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/macsidigital/laravel-xero)[![Build Status](https://camo.githubusercontent.com/a29c444327246888e60d482f4a8b77ee03252804467dc6085e9a40718e8578d3/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d616373696469676974616c2f6c61726176656c2d7865726f2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/MacsiDigital/laravel-xero)[![StyleCI](https://camo.githubusercontent.com/f3e22b30241d9230002c13c41a45f3d27d582f18477c203f085a722ac0508420/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3139333538383935382f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/193588958)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/93a8c58b22f4caff0b0b3394ad6bb1ece5565b1578150c3e3943439cefa65fa8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4d616373694469676974616c2f6c61726176656c2d7865726f2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/MacsiDigital/laravel-xero/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/e349c5952c29a62d5a3e58314acf0824e80bac1aacb1946804d9dbc075247fe3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616373696469676974616c2f6c61726176656c2d7865726f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/macsidigital/laravel-xero)

A little Laravel package to communicate with Xero.

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

[](#installation)

You can install the package via composer:

```
composer require macsidigital/laravel-xero
```

The service provider should automatically register for For Laravel &gt; 5.4.

For Laravel &lt; 5.5, open config/app.php and, within the providers array, append:

```
MacsiDigital\Xero\Providers\XeroServiceProvider::class
```

Configuration file
------------------

[](#configuration-file)

Publish the configuration file

```
php artisan vendor:publish --provider="MacsiDigital\Xero\Providers\XeroServiceProvider"
```

This will create a xero/config.php within your config directory. Check the Xero documentation for the relevant values in the config.php file. Ensure that the location of the RSA keys matches.

Usage
-----

[](#usage)

Everything has been setup to be similar to Laravel syntax.

We also use a little bit of magic to work with Xero's model names. In Xero there are a few different modules (Accounting, Payroll AU etc.), at the minute we only support a small part of the accounting area, but we have set naming so that additional modules can be added in future.

If the response is anything other than a '200' then we will throw an exception, so use try catch blocks.

So to use the conacts in the Accounting module we would use the following syntax.

```
	$xero = new \MacsiDigital\Xero\Xero;
	$xero->AccountingContact->functionName();
```

Find all
--------

[](#find-all)

The find all function returns a Laravel Collection so you can use all the Laravel Collection magic

```
	$xero = new \MacsiDigital\Xero\Xero;
	$contacts = $xero->AccountingContact->all();
```

Filtered
--------

[](#filtered)

The filtered find function returns a Laravel Collection so you can use all the Laravel Collection magic

```
	$xero = new \MacsiDigital\Xero\Xero;
	$contacts = $xero->AccountingContact->where('Name', '=', 'Test Name')->get();
```

To only get a single item use the 'first' method

```
	$xero = new \MacsiDigital\Xero\Xero;
	$contact = $xero->AccountingContact->where('Name', '=', 'Test Name')->first();
```

You can also just passs the name and value if it is to equal

```
	$xero = new \MacsiDigital\Xero\Xero;
	$contact = $xero->AccountingContact->where('Name', 'Test Name')->get();
	$contact = $xero->AccountingContact->where('Name', 'Test Name')->first();
```

Find by ID
----------

[](#find-by-id)

Just like Laravel we can use the 'find' method to return a single matched result on the ID

```
	$xero = new \MacsiDigital\Xero\Xero;
	$contact = $xero->AccountingContact->find('ID_String');
```

Creating Items
--------------

[](#creating-items)

We can create and update records using the save function, below is the full save script for a creation. Please note the functions for adding multi array items, like addresses.

```
	$contact = $xero->AccountingContact->make([
        'Name' => 'Test Name',
        'FirstName' => 'First Name',
        'LastName' => 'Last Name',
        'EmailAddress' => 'test@test.com',
        'IsCustomer' => true,
    ]);
    $contact->addAddress($xero->AccountingAddress->make([
        'AddressType' => 'POBOX',
        'AddressLine1' => 'Test1',
        'AddressLine2' => 'Test2',
        'AddressLine3' => 'Test3',
        'City' => 'City',
        'PostalCode' => 'Test Code',
        'Country' => 'Test Country',
    ]));
    $contact->save();
```

Example
-------

[](#example)

Here is an example usage case for querying for a contact, creating if not found and then creating an invoice

```
	$contact = $xero->AccountingContact->where('name', 'Test Name')->first();
    if($contact == null){
        $contact = $xero->AccountingContact->make([
	        'Name' => 'Test Name',
	        'FirstName' => 'First Name',
	        'LastName' => 'Last Name',
	        'EmailAddress' => 'test@test.com',
	        'IsCustomer' => true,
	    ]);
	    $contact->addAddress($xero->AccountingAddress->make([
	        'AddressType' => 'POBOX',
	        'AddressLine1' => 'Test1',
	        'AddressLine2' => 'Test2',
	        'AddressLine3' => 'Test3',
	        'City' => 'City',
	        'PostalCode' => 'Test Code',
	        'Country' => 'Test Country',
	    ]));
	    $contact->save();
    }
    $invoice = $xero->AccountingInvoice->make([
        'Contact' => $contact,
    ]);
    $invoice->addLineItem($xero->AccountingLineItem->make([
        'Description' => 'Test Description',
        'Quantity' => '1',
        'UnitAmount' => '1234.56',
        'AccountCode' => '200'
    ]));
    $invoice->save();
```

Resources
---------

[](#resources)

At present we have the following resources

- Account
- Contacts
- Invoices
- Payments
- PrePayments
- OverPayments
- CreditNotes

We plan to add more resources in the future but setting up additional models is straight forward, below is the invoice model setup. If you create any models, then create a pull request and we will add into main repo.

```
	namespace MacsiDigital\Xero;

	use MacsiDigital\Xero\Support\Model;

	class AccountingInvoice extends Model
	{
	    const ENDPOINT = 'Invoices';
	    const NODE_NAME = 'Invoice';
	    const KEY_FIELD = 'InvoiceID';

	    protected $methods = ['get', 'post', 'put'];

	    protected $attributes = [
	    	'Type' => 'ACCREC',
	        'Contact' => '',
	        'LineItems' => [],
	        'Date' => '',
	        'DueDate' => '',
	        'LineAmountTypes' => '',
	        'InvoiceNumber' => '',
	        'Reference' => '',
	        'BrandingThemeID' => '',
	        'Url' => '',
	        'CurrencyCode' => '',
	        'CurrencyRate' => '',
	        'Status' => '',
	        'SentToContact' => '',
	        'ExpectedPaymentDate' => '',
	        'PlannedPaymentDate' => '',
	        'SubTotal' => '',
	        'TotalTax' => '',
	        'Total' => '',
	        'TotalDiscount' => '',
	        'InvoiceID' => '',
	        'HasAttachments' => '',
	        'Payments' => [],
	        'Prepayments' => [],
	        'Overpayments' => [],
	        'AmountDue' => '',
	        'AmountPaid' => '',
	        'FullyPaidOnDate' => '',
	        'AmountCredited' => '',
	        'UpdatedDateUTC' => '',
	        'CreditNotes' => []
	    ];

	    protected $relationships = [
	        'Contact' => '\MacsiDigital\Xero\Models\Accounting\Contact',
	        'LineItems' => '\MacsiDigital\Xero\Models\Accounting\LineItem',
	        'Payments' => '\MacsiDigital\Xero\Models\Accounting\Payment',
	        'Prepayments' => '\MacsiDigital\Xero\Models\Accounting\Prepayment',
	        'Overpayments' => '\MacsiDigital\Xero\Models\Accounting\Overpayment',
	    ];

	    public function addLineItem($item)
	    {
	        $this->attributes['LineItems'][] = $item;
	    }
	}
```

### Testing

[](#testing)

At present there is no PHP Unit Testing, but we plan to add it in the future.

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Colin Hall](https://github.com/macsidigital)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~15 days

Recently: every ~55 days

Total

22

Last Release

2188d ago

Major Versions

v1.x-dev → v2.x-dev2020-05-15

v2.x-dev → v3.x-dev2020-05-15

PHP version history (4 changes)1.0.0PHP ^7.1

1.0.16PHP ^7.2

1.1.0PHP ^7.2|^7.3

v2.x-devPHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/134dcd0c87f691d2f351f4bff03eb390871de1992f1a79ecf034b4ac53b4ca71?d=identicon)[MacsiDigital](/maintainers/MacsiDigital)

---

Top Contributors

[![colinhall17](https://avatars.githubusercontent.com/u/5073205?v=4)](https://github.com/colinhall17 "colinhall17 (59 commits)")

---

Tags

hacktoberfestmacsidigitallaravel-xero

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/macsidigital-laravel-xero/health.svg)

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

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[macsidigital/laravel-api-client

Laravel API Client Builder package

20382.7k6](/packages/macsidigital-laravel-api-client)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[grantholle/powerschool-api

A Laravel package to make interacting with PowerSchool less painful.

1715.6k1](/packages/grantholle-powerschool-api)

PHPackages © 2026

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