PHPackages                             kennethsolomon/xero-laravel - 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. [Database &amp; ORM](/categories/database)
4. /
5. kennethsolomon/xero-laravel

ActiveLibrary[Database &amp; ORM](/categories/database)

kennethsolomon/xero-laravel
===========================

💸 Access the Xero accounting system using an Eloquent-like syntax

3.1.2(3y ago)13LGPL-3.0-onlyPHPPHP &gt;=7.1

Since Dec 13Pushed 3y agoCompare

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

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

💸 Xero Laravel
==============

[](#-xero-laravel)

Xero Laravel allows developers to access the Xero accounting system using an Eloquent-like syntax.

Please note that this version of Xero Laravel supports the Xero OAuth 2.0 implementation. Older Xero apps using OAuth 1.x are no longer supported.

 [![](assets/images/xero-laravel-usage.png)](assets/images/xero-laravel-usage.png)

 [ ![StyleCI](https://camo.githubusercontent.com/42c9ded2be34b5c3a141c20f5f24e09f790acf364f4e57958037a4c61b0c598c/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3135333235363436392f736869656c643f6272616e63683d6d6173746572) ](https://github.styleci.io/repos/153256469) [ ![](https://camo.githubusercontent.com/8715f83bdc5fb56ee48ca6c08345337002b936e09431c2c30c0b99a95f12efaa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4b656e6e657468536f6c6f6d6f6e2f7865726f2d6c61726176656c2e737667) ](https://packagist.org/packages/KennethSolomon/xero-laravel/stats)

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

[](#installation)

Xero Laravel can be easily installed using Composer. Just run the following command from the root of your project.

```
composer require KennethSolomon/xero-laravel
```

If you have never used the Composer dependency manager before, head to the [Composer website](https://getcomposer.org/) for more information on how to get started.

Setup
-----

[](#setup)

First, run the following `artisan` command from the root of your project. This will publish the package configuration file.

```
php artisan vendor:publish --provider="KennethSolomon\XeroLaravel\Providers\XeroLaravelServiceProvider"
```

You now need to populate the `config/xero-laravel-lf.php` file with the credentials for your Xero app(s). You can create apps and find the required credentials in the [My Apps](https://developer.xero.com/myapps/)section of your Xero account.

If you only intend to use one Xero app, the standard configuration file should be sufficient. All you will need to do is add the following variables to your `.env` file.

```
XERO_CLIENT_ID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XERO_CLIENT_SECRET=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XERO_REDIRECT_URI=https://example.com/xero-callback

```

### OAuth 2.0 flow

[](#oauth-20-flow)

In order for users to make use of your Xero app, they must first give your app permission to access their Xero account. To do this, your web application must do the following.

1. Redirect the user to the Xero authorization URL.
2. Capture the response from Xero, and obtain an access token.
3. Retrieve the list of tenants (typically Xero organisations), and let the user select one.
4. Store the access token and selected tenant ID against the user's account for future use.
5. Before using the access token, check if it has expired and refresh it if necessary.

The controller below shows these steps in action.

```
