Download the PHP package webfox/laravel-xero-oauth2 without Composer

On this page you can find all versions of the php package webfox/laravel-xero-oauth2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-xero-oauth2

A Laravel integration for Xero using the Oauth 2.0 spec

Latest Version on Packagist Total Downloads

This package integrates the new recommended package of xeroapi/xero-php-oauth2 using the Oauth 2.0 spec with Laravel.

Installation

You can install this package via composer using the following command:

The package will automatically register itself.

You should add your Xero keys to your .env file using the following keys:

(on Xero developer portal): IMPORTANT When setting up the application in Xero ensure your redirect url is:

(The flow is xero/auth/callback performs the oAuth handshake and stores your token, then redirects you over to your success callback)

You can publish the configuration file with:

Scopes

You'll want to set the scopes required for your application in the config file.

The default set of scopes are openid, email, profile, offline_access, and accounting.settings. You can see all available scopes on the official Xero documentation.

Using the Package

This package registers two bindings into the service container you'll be interested in:

app\Http\Controllers\XeroController.php

resources\views\xero.blade.php

routes/web.php

Error Handling

In the event that a user denies access on the Xero Authorisation page, the package will throw a OAuthException from the AuthorizationCallbackController. This can be caught and acted upon however you prefer.

Laravel 11

To do this in Laravel 11, bind a custom exception renderer in bootstrap/app.php:

Laravel 8-10

Use the reportable method in the App\Exceptions\Handler class:

Credential Storage

Credentials are stored in a JSON file using the default disk on the Laravel Filesystem, with visibility set to private. This allows credential sharing across multiple servers using a shared disk such as S3, regardless of which server conducted the OAuth flow.

To use a different disk, change the xero.credential_disk config item to another disk defined in config/filesystem.php.

You can switch out the credential store (e.g. for your own UserStore if you wanted to store the credentials against your user) in one of two ways:

  1. If it's a simple store and Laravel can automatically resolve your bindings, simply change the xero.credential_store config key to point to your new implementation.
  2. If it requires more advanced logic (e.g. using the current user to retrieve the credentials) then you can rebind this in your AppServiceProvider or a Middleware e.g.

An example UserStorageProvider can been found here

Using Webhooks

On your application in the Xero developer portal create a webhook to get your webhook key.

You can then add this to your .env file as

You can then setup a controller to handle your webhook and inject \Webfox\Xero\Webhook e.g.

Example calls

This package is simply a bridge so you don't have to deal with the Oauth2 gymnastics in Laravel.

Once you've have an instance of \XeroAPI\XeroPHP\Api\AccountingApi::class you're dealing directly with Xero's api library.

The XeroAPI PHP Oauth2 App repository has this list of examples of implementing calls to the API: e.g. invoice creation etc.

https://github.com/XeroAPI/xero-php-oauth2-app/blob/master/example.php

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-xero-oauth2 with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0|^8.1
xeroapi/xero-php-oauth2 Version ^2.0|^3.0|^4.0|^5.0|^6.0|^7.0
laravel/framework Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webfox/laravel-xero-oauth2 contains the following files

Loading the files please wait ....