VentureCraft / xero-laravel by duellsy

Xero Service Provider for Laravel 4
3,257
3
3
Package Data
Maintainer Username: duellsy
Maintainer Contact: chris@venturecraft.com.au (Chris Duell)
Package Create Date: 2014-03-27
Package Last Update: 2015-04-18
Home Page: http://www.venturecraft.com.au
Language: PHP
License: MIT
Last Refreshed: 2024-04-26 03:21:44
Package Statistics
Total Downloads: 3,257
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 3
Total Watchers: 3
Total Forks: 2
Total Open Issues: 1

Xero Service Provider for Laravel 4

Originally forked from https://github.com/Softlabs/xero-laravel

A simple Laravel 4 service provider for including the PHP Xero API.

Installation

The Xero Service Provider can be installed via Composer by requiring the Venturecraft/xero-laravel package and setting the minimum-stability to dev in your project's composer.json.

{
	"require": {
		"laravel/framework": "4.0.*",
		"venturecraft/xero-laravel": "dev-master"
	},
	"minimum-stability": "dev"
}

Usage

To use the Xero Service Provider, you must register the provider when bootstrapping your Laravel application.

Use Laravel Configuration

Create a new app/config/xero.php configuration file with the following options:

return array(
    'key'           => '<your-xero-key>',
    'secret'        => '<your-xero-secret>',
    'publicPath'    => '../app/config/xero/publickey.cer',
    'privatePath'   => '../app/config/xero/privatekey.pem'
);

Find the providers key in app/config/app.php and register the Xero Service Provider.

    'providers' => array(
        // ...
        'Venturecraft\XeroLaravel\XeroLaravelServiceProvider',
    )

Find the aliases key in app/config/app.php and add in our Xero alias.

    'aliases' => array(
        // ...
        'XeroLaravel' 	  => 'Venturecraft\XeroLaravel\Facades\XeroLaravel',
    )

Setting up the application

Create public and private keys, and save them in /app/config/xero/ as publickey.cer and privatekey.pem.

For more info on setting up your keys, check out the Xero documentation

Example Usage

Create Contact

$contact = array(
    array(
       	"Name"        => $user['company']['name'],
       	"FirstName"   => $user['firstname'],
		"LastName"    => $user['surname'],
	)
);

$xero_contact = XeroLaravel::Contacts($contact);

Get Contacts with WHERE clause & paging

$where = "ContactNumber!=null&IsCustomer=true";
$page  = 1;
print_r(XeroLaravel::Contacts(false, false, $where, false, $page));

Reference