2017 © Pedro Peláez
 

library xerolaravel

A Laravel 5 wrapper for Xero's PHP API

image

drawmyattention/xerolaravel

A Laravel 5 wrapper for Xero's PHP API

  • Tuesday, December 12, 2017
  • by drawmyattention
  • Repository
  • 7 Watchers
  • 32 Stars
  • 52,116 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 24 Forks
  • 10 Open issues
  • 14 Versions
  • 10 % Grown

The README.md

Packagist, (*1)

Xero Accounting API Laravel 5 Wrapper

A Laravel 5 wrapper for calcinai/xero-php (a custom API for integrating with Xero)., (*2)

Installation via Composer

Require the package, (*3)

composer require drawmyattention/xerolaravel "1.0.*"

Add the Service Provider to your config/app.php under providers, (*4)

'DrawMyAttention\XeroLaravel\Providers\XeroServiceProvider',

**Register the Facades within config/app.php under aliases, (*5)

'XeroPrivate'=> 'DrawMyAttention\XeroLaravel\Facades\XeroPrivate',

Publish the configuration file, (*6)

php artisan vendor:publish

This will create a xero/config.php within your config directory. (Note: Ensure that you have generated the necessary tokens and have generated the RSA keys required by Xero for authentication.) Edit the relevant values in the config.php file., (*7)

Ensure that the location of the RSA keys matches the required format (file://absolutepath), (*8)

Dependencies and Requirements

This Service Provider current wraps the calcinai/xero-php version 1.1.* package., (*9)

Additionally, you must have PHP installed with the following extensions:, (*10)

  • php_curl (7.30+)
  • php_openssl

Usage

There are two ways to use the classes: via the IoC container, or via a Facade. They both offer the same functionality, so use each depending on your preference., (*11)

Get all invoices

Facade, (*12)

$invoices = XeroPrivate::load('Accounting\\Invoice')->execute();

IoC Container, (*13)

// Create an instance of the class, resolved out of the IoC container
$xero = $this->app->make('XeroPrivate');

$invoices = $xero->load('Accounting\\Invoice')->execute();

Get a single invoice via GUID or invoice number

Facade, (*14)

$invoice = XeroPrivate::loadByGUID('Accounting\\Invoice', 'inv-0004);

IoC Container, (*15)

$xero = $this->app->make('XeroPrivate');

$invoice = $xero->loadByGUID('Accounting\\Invoice', 'inv-0004);

Update an existing invoice

Facade, (*16)

$invoice = XeroPrivate::loadByGUID('Accounting\\Invoice', 'inv-0004);

$invoice->setStatus('Paid');

XeroPrivate::save($invoice);

IoC Container, (*17)

$xero = $this->app->make('XeroPrivate');

$invoice = $xero->loadByGUID('Accounting\\Invoice', 'inv-0004);

$invoice->setStatus('Paid');

$xero->save($invoice);

Creating a new invoice

/* 
 * Resolve instances of Xero, XeroInvoice, XeroContact 
 * and XeroInvoiceLine out of the IoC container.
 */

$xero = $this->app->make('XeroPrivate');
$invoice = $this->app->make('XeroInvoice');
$contact = $this->app->make('XeroContact');
$line1 = $this->app->make('XeroInvoiceLine');
$line2 = $this->app->make('XeroInvoiceLine');

// Set up the invoice contact
$contact->setAccountNumber('DMA01');
$contact->setContactStatus('ACTIVE');
$contact->setName('Amo Chohan');
$contact->setFirstName('Amo');
$contact->setLastName('Chohan');
$contact->setEmailAddress('amo.chohan@gmail.com');
$contact->setDefaultCurrency('GBP');

// Assign the contact to the invoice
$invoice->setContact($contact);

// Set the type of invoice being created (ACCREC / ACCPAY)
$invoice->setType('ACCREC');

$dateInstance = new DateTime();
$invoice->setDate($dateInstance);
$invoice->setDueDate($dateInstance);
$invoice->setInvoiceNumber('DMA-00001');
$invoice->setReference('DMA-00001');

// Provide an URL which can be linked to from Xero to view the full order
$invoice->setUrl('http://yourdomain/fullpathtotheorder');

$invoice->setCurrencyCode('GBP');
$invoice->setStatus('Draft');

// Create some order lines
$line1->setDescription('Blue tshirt');

$line1->setQuantity(1);
$line1->setUnitAmount(99.99);
$line1->setTaxAmount(0);
$line1->setLineAmount(99.99);
$line1->setDiscountRate(0); // Percentage

// Add the line to the order
$invoice->addLineItem($line1);

// Repeat for all lines...

$xero->save($invoice);

Creating Attachments

$xero = $this->app->make('XeroPrivate');

$attachment = $this->app->make('XeroAttachment')
    ->createFromLocalFile(storage_path('your_file.pdf'));

$invoice = $xero->loadByGUID('Accounting\\Invoice', 'AMO-00002');
$invoice->addAttachment($attachment);

The Versions

12/12 2017

dev-master

9999999-dev

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

12/12 2017

v1.2.1

1.2.1.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

20/10 2017

v1.2.0

1.2.0.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

20/10 2017

dev-dev-develop

dev-dev-develop

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

09/12 2016

v1.1.0

1.1.0.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

08/02 2016

v1.0.8

1.0.8.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

18/08 2015

v1.0.7

1.0.7.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

22/06 2015

v1.0.6

1.0.6.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

22/06 2015

v1.0.5

1.0.5.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

  • drawmyattention/xero-php dev-attachmentfix

 

22/06 2015

v1.0.4

1.0.4.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

22/06 2015

v1.0.3

1.0.3.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

  • drawmyattention/xero-php 1.2.1

 

17/06 2015

v1.0.2

1.0.2.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

16/06 2015

v1.0.1

1.0.1.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires

 

16/06 2015

v1.0.0

1.0.0.0

A Laravel 5 wrapper for Xero's PHP API

  Sources   Download

The Requires