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

ActiveLibrary

dedomorozoff/laravel-xero-dedo
==============================

A Laravel Xero package

1.0.1(2y ago)026MITPHP

Since May 31Pushed 2y agoCompare

[ Source](https://github.com/dedomorozoff/laravel-xero)[ Packagist](https://packagist.org/packages/dedomorozoff/laravel-xero-dedo)[ Docs](https://github.com/dcblogdev/laravel-xero)[ GitHub Sponsors](https://github.com/dcblogdev)[ RSS](/packages/dedomorozoff-laravel-xero-dedo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/77228d014f87bf573869bd92597eae71c0256a95ec004cd5d53d83f9f4f9b9bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6463626c6f676465762f6c61726176656c2d7865726f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dcblogdev/laravel-xero)[![Total Downloads](https://camo.githubusercontent.com/4bc9c4cf1898c89275f0289533bbcc8eb53db4e97bbb69c8271186feae3c6afd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6463626c6f676465762f6c61726176656c2d7865726f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dcblogdev/laravel-xero)

[![Logo](https://repository-images.githubusercontent.com/317929912/1e40a180-49c1-11eb-893d-af9c59d29ad5)](https://repository-images.githubusercontent.com/317929912/1e40a180-49c1-11eb-893d-af9c59d29ad5)

Laravel package for working with the Xero API

Watch a video walkthrough

Xero API documentation can be found at:

Before you can integrate with Xero you will need to create an app, go to  to register a new app.

For the grant type select, Auth code (web app)

For OAuth 2.0 redirect URI enter the full URL you want to use for connection to Xero from your application such as

Install
=======

[](#install)

You can install the package via composer:

```
composer require dcblogdev/laravel-xero

```

Config
======

[](#config)

You can publish the config file with:

```
php artisan vendor:publish --provider="Dcblogdev\Xero\XeroServiceProvider" --tag="config"

```

Migration
=========

[](#migration)

You can publish the migration with:

```
php artisan vendor:publish --provider="Dcblogdev\Xero\XeroServiceProvider" --tag="migrations"

```

After the migration has been published you can create the tokens tables by running the migration:

```
php artisan migrate

```

.ENV Configuration Ensure you've set the following in your .env file:

```
XERO_CLIENT_ID=
XERO_CLIENT_SECRET=
XERO_REDIRECT_URL=https://domain.com/xero/connect
XERO_LANDING_URL=https://domain.com/xero
XERO_WEBHOOK_KEY=

```

Middleware
==========

[](#middleware)

To restrict access to routes only to authenticated users there is a middleware route called XeroAuthenticated

Add XeroAuthenticated to routes to ensure the user is authenticated:

```
Route::group(['middleware' => ['web', 'XeroAuthenticated'], function()
```

To access token model reference this ORM model:

```
use Dcblogdev\Xero\Models\XeroToken;
```

Multi-tenancy
=============

[](#multi-tenancy)

To set the tenant call `setTenantId` and pass in your tenant\_id

Once set all calls will use the set tenant.

```
setTenantId($tenant_id)
```

Commands
========

[](#commands)

Refresh Token
-------------

[](#refresh-token)

When using Xero as a background process, tokens will need to be renwed, to automate this process use the command:

```
php artisan xero:keep-alive

```

This will refresh the token when its due to expire. Its recommended to add this to a schedule ie inside `App\Console\Kernal.php` add the command to a schedule.

```
protected function schedule(Schedule $schedule)
{
    $schedule->command('xero:keep-alive')->everyFiveMinutes();
}
```

Usage
=====

[](#usage)

A routes example:

```
Route::group(['middleware' => ['web', 'auth']], function(){
    Route::get('xero', function(){

        if (! Xero::isConnected()) {
            return redirect('xero/connect');
        } else {
            //display your tenant name
            return Xero::getTenantName();
        }

    });

    Route::get('xero/connect', function(){
        return Xero::connect();
    });
});
```

Or using a middleware route, if the user does not have a token then automatically redirect to get authenticated:

```
Route::group(['middleware' => ['web', 'XeroAuthenticated']], function(){
    Route::get('xero', function(){
        return Xero::getTenantName();
    });
});
```

```
Route::get('xero/connect', function(){
    return Xero::connect();
});
```

Once authenticated you can call Xero:: with the following verbs:

```
Xero::get($endpoint, $array = [])
Xero::post($endpoint, $array = [])
Xero::put($endpoint, $array = [])
Xero::patch($endpoint, $array = [])
Xero::delete($endpoint, $array = [])
```

The second param of array is not always required, its requirement is determined from the endpoint being called, see the API documentation for more details.

These expect the API endpoints to be passed, the URL  is provided, only endpoints after this should be used ie:

```
Xero::get('contacts')
```

Is Connected
============

[](#is-connected)

Anytime you need to check if Xero is authenticated you can call a -&gt;isConnected method. The method returns a boolean.

To do an action when a Xero is not connected can be done like this:

```
if (! Xero::isConnected()) {
    return redirect('xero/connect');
}
```

Disconnect
==========

[](#disconnect)

To disconnect from Xero call a -&gt;disconnect() method.

The disconnect will send a POST request to Xero to revoke the connection, in addition, the stored token will be deleted.

```
Xero::disconnect();
```

Typically you only want to run this is there is a connection, so it makes sense to wrap this in a -&gt;isConnected() check:

```
if (Xero::isConnected()) {
    Xero::disconnect();
}
```

Contacts
========

[](#contacts)

Xero provides a clean way of working with Xero contacts.

To work with contacts first call -&gt;contacts() followed by a method.

```
Xero::contacts()
```

List Contacts
-------------

[](#list-contacts)

To list contacts call the contacts()-&gt;get() method.

Xero docs for listing contacts -

The optional parameters are $page and $where. $page defaults to 1 which means being back on the first page, for additional pages enter higher page numbers until there are no pages left to return. The API does not offer a count to determine how many pages there are.

```
Xero::contacts()->get(int $page = 1, string $where = null)
```

$where allows for filter options to be passed, the most common filters have been optimised to ensure performance across organisations of all sizes. We recommend you restrict your filtering to the following optimised parameters.

Filter by name:

```
Xero::contacts()->get(1, 'Name="ABC limited"')
```

Filter by email:

```
Xero::contacts()->get(1, 'EmailAddress="email@example.com"')
```

Filter by account number:

```
Xero::contacts()->get(1, 'AccountNumber="ABC-100"')
```

View Contact
------------

[](#view-contact)

To view a single contact a find method can be called passing in the contact id

```
Xero::contacts()->find(string $contactId)
```

Create Contacts
---------------

[](#create-contacts)

To create a contact call a store method passing in an array of contact data:

See  for the array contents specifications

```
Xero::contacts()->store($data)
```

Update Contact
--------------

[](#update-contact)

To update a contact 2 params are required the contact Id and an array of data to be updated:

See  for details on the fields that can be updated.

```
Xero::contacts()->update($contactId, $data);
```

Invoices
========

[](#invoices)

Xero provides a clean way of working with Xero invoices.

To work with invoices first call -&gt;invocies() followed by a method.

```
Xero::invoices()
```

List Invoices
-------------

[](#list-invoices)

To list invoices call the invoices()-&gt;get() method.

Xero docs for listing invoices -

The optional parameters are $page and $where. $page defaults to 1 which means being back on the first page, for additional pages enter higher page numbers until there are no pages left to return. The API does not offer a count to determine how many pages there are.

```
Xero::invoices()->get(int $page = 1, string $where = null)
```

$where allows for filter options to be passed, the most common filters have been optimised to ensure performance across organisations of all sizes. We recommend you restrict your filtering to the following optimised parameters.

Filter by status:

```
Xero::invoices()->get(1, 'Status="AUTHORISED"')
```

Filter by contact id:

```
Xero::invoices()->get(1, 'Contact.ContactID=guid("96988e67-ecf9-466d-bfbf-0afa1725a649")')
```

Filter by contact number

```
Xero::invoices()->get(1, 'Contact.ContactNumber="ID001"')
```

Filter by reference

```
Xero::invoices()->get(1, 'Reference="INV-0001"')
```

Filter by date

```
Xero::invoices()->get(1, 'Date=DateTime(2020, 01, 01)')
```

Filter by type

```
Xero::invoices()->get(1, 'Type="ACCREC"')
```

View Invoice
------------

[](#view-invoice)

To view a single invoice a find method can be called passing in the invoice id

```
Xero::invoices()->find(string $invoiceId)
```

Online Invoice
--------------

[](#online-invoice)

For invoices created that have a status of either Submitted, Authorised, or Paid an online invoice can be seen by calling onlineUrl passing in the invoiceId

```
Xero::invoices()->onlineUrl($invoiceId)
```

Create Invoice
--------------

[](#create-invoice)

To create a invoice call a store method passing in an array of invoice data:

See  for the array contents specifications

```
Xero::invoices()->store($data)
```

Update Invoice
--------------

[](#update-invoice)

To update an invoice 2 params are required the invoice Id and an array of data to be updated:

See  for details on the fields that can be updated.

```
Xero::invoices()->update($invoiceId, $data);
```

PDF resources
-------------

[](#pdf-resources)

Some Xero resources support being downloaded as PDF. To do this you can:

```
$pdfInvoice = Xero::get("invoices/{$invoiceId}", null, true, 'application/pdf');
$pdfInvoice['body']; // will be the pdf as a pdf string for you to write out to storage etc.
```

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

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

[](#contributing)

Contributions are welcome and will be fully credited.

Contributions are accepted via Pull Requests on [Github](https://github.com/dcblogdev/laravel-xero).

Pull Requests
-------------

[](#pull-requests)

- **Document any change in behaviour** - Make sure the `readme.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

Security
--------

[](#security)

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

License
-------

[](#license)

license. Please see the [license file](license.md) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.5% 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

Unknown

Total

1

Last Release

1077d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/695eae2e209e316b719525ecf7f462b3169cfb65351e378f8a6e1ceb3410d57d?d=identicon)[dedomorozoff](/maintainers/dedomorozoff)

---

Top Contributors

[![dcblogdev](https://avatars.githubusercontent.com/u/1018170?v=4)](https://github.com/dcblogdev "dcblogdev (37 commits)")[![tonypartridge](https://avatars.githubusercontent.com/u/1400982?v=4)](https://github.com/tonypartridge "tonypartridge (6 commits)")[![dedomorozoff](https://avatars.githubusercontent.com/u/5643835?v=4)](https://github.com/dedomorozoff "dedomorozoff (3 commits)")[![rjocoleman](https://avatars.githubusercontent.com/u/154176?v=4)](https://github.com/rjocoleman "rjocoleman (3 commits)")[![craigAtCD](https://avatars.githubusercontent.com/u/152445143?v=4)](https://github.com/craigAtCD "craigAtCD (2 commits)")[![ashleyhood](https://avatars.githubusercontent.com/u/4114910?v=4)](https://github.com/ashleyhood "ashleyhood (2 commits)")[![kurtnoone](https://avatars.githubusercontent.com/u/2835218?v=4)](https://github.com/kurtnoone "kurtnoone (1 commits)")

---

Tags

laravelxero

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[dcblogdev/laravel-xero

A Laravel Xero package

53129.1k1](/packages/dcblogdev-laravel-xero)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)

PHPackages © 2026

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