PHPackages                             ayles-software/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. [API Development](/categories/api)
4. /
5. ayles-software/xero-laravel

ActiveLibrary[API Development](/categories/api)

ayles-software/xero-laravel
===========================

Laravel wrapper for Xero

3.7.0(2mo ago)217.0k↑405.6%2[1 issues](https://github.com/ayles-software/xero-laravel/issues)MITPHPPHP ^8.3

Since Feb 21Pushed 2mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (6)Versions (20)Used By (0)

Xero Laravel
============

[](#xero-laravel)

Xero Laravel provides a wrapper around xero.

Requirements
------------

[](#requirements)

- Laravel 6+
- PHP 7.2+

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

[](#installation)

Install via using composer

```
composer require ayles-software/xero-laravel
```

Setup
-----

[](#setup)

Publish the config.

```
php artisan vendor:publish --provider="AylesSoftware\XeroLaravel\ServiceProvider"
```

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

```
XERO_REDIRECT_URL=
XERO_CLIENT_ID=
XERO_CLIENT_SECRET=

```

The config file also contains scopes Xero access. The `offline_access` scope is required to obtain a new access token. Access tokens **expire after 30 minutes**. For more information on scopes try the [xero documentation](https://developer.xero.com/documentation/oauth2/scopes).

#### Migrations

[](#migrations)

This package uses `XeroAccess` model to manage access tokens. Run the migration to create this table.

OAuth flow
----------

[](#oauth-flow)

First you must authorize the application, this will require a controller and route to be setup. Once the application has been authorized then access to Xero is self managed within this package. Once the access token expires, a new one will be request as needed.

`XeroOAuth::class` will provides the OAuth flow and regeneration of the access token.

Example of Controller for authorization.

```
