Download the PHP package langleyfoxall/xero-laravel without Composer
On this page you can find all versions of the php package langleyfoxall/xero-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download langleyfoxall/xero-laravel
More information about langleyfoxall/xero-laravel
Files in langleyfoxall/xero-laravel
Package xero-laravel
Short Description 💸 Access the Xero accounting system using an Eloquent-like syntax
License LGPL-3.0-only
Informations about the package 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.
Installation
Xero Laravel can be easily installed using Composer. Just run the following command from the root of your project.
If you have never used the Composer dependency manager before, head to the Composer website for more information on how to get started.
Setup
First, run the following artisan
command from the root of your project. This
will publish the package configuration file.
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
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.
OAuth 2.0 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.
- Redirect the user to the Xero authorization URL.
- Capture the response from Xero, and obtain an access token.
- Retrieve the list of tenants (typically Xero organisations), and let the user select one.
- Store the access token and selected tenant ID against the user's account for future use.
- Before using the access token, check if it has expired and refresh it if necessary.
The controller below shows these steps in action.
By default, only a limited number of scopes are defined in the configuration file (space separated). You will probably
want to add to the scopes depending on your application's intended purpose. For example adding the
accounting.transactions
scope allows you to manage invoices, and adding the accounting.contacts.read
allows you to
read contact information.
Xero's documentation provides a full list of available scopes.
Usage
To use Xero Laravel, you first need to get retrieve your user's stored access token and tenant id. You can use these
to create a new XeroApp
object which represents your Xero application.
You can then immediately access Xero data using Eloquent-like syntax. The following code snippet shows the available syntax. When multiple results are returned from the API they will be returned as Laravel Collection.
Available relationships
The list below shows all available relationships that can be used to access
data related to your Xero application (e.g. $xero->relationshipName
).
Note: Some of these relationships may not be available if the related service(s) are not enabled for your Xero account.
All versions of xero-laravel with dependencies
laravel/framework Version ^5.1||^6.0||^7.0||^8.0||^9.0||^10.0||^11.0
calcinai/xero-php Version ^2.2.2