fourlabs/xero-bundle

Symfony bundle wrapping the XeroPHP library

Installs: 13 462

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 4

Open Issues: 0

Type:symfony-bundle

1.2.0 2018-07-10 11:14 UTC

This package is auto-updated.

Last update: 2024-12-22 07:54:22 UTC


README

StyleCI Total Downloads

This is a Symfony bundle wrapping the XeroPHP library. From the library's github page:

A client implementation of the Xero API, with a cleaner OAuth interface and ORM-like abstraction.

I hate reinventing the wheel, but this was written out of desperation. I wasn't comfortable putting the implementation that's recommended by Xero in to production, even after persisting with extending it.

This is loosely based on the functional flow of XeroAPI/XeroOAuth-PHP, but is split logically into more of an OO design.

Download the bundle using composer

composer require fourlabs/xero-bundle

Enable the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FL\XeroBundle\FLXeroBundle(),
        // ...
    );
}

Configure the bundle

For a full configuration reference use:

php bin/console config:dump-reference FLXeroBundle

Example of a private app configuration:

fl_xero:
  type: private
  oauth:
    callback: "https://mydomain.com/xero-callback"
    consumer_key: "%xero_consumer_key%"
    consumer_secret: "%xero_consumer_secret%"
    rsa_private_key: "file://%kernel.root_dir%/Resources/Xero/private.pem"
  curl:
    CURLOPT_USERAGENT: XeroPHP Test App

Usage

Using the Xero service in your controller:

$xero = $this->get('fl_xero.app');

$contacts = $xero->load('Accounting\\Contact')->execute();
foreach ($contacts as $contact) {
    var_dump($contact);
}