2017 © Pedro Peláez
 

symfony-bundle harvest-app-bundle

Symfony2 wrapper around HaPi Harvest API client for app usage

image

mattvick/harvest-app-bundle

Symfony2 wrapper around HaPi Harvest API client for app usage

  • Saturday, October 13, 2012
  • by mattvick
  • Repository
  • 2 Watchers
  • 0 Stars
  • 293 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Introduction

Symfony2 wrapper around HaPi Harvest API client for app usage., (*1)

MattvickHarvestAppBundle is just a simple proxy bundle between HaPi HarvestAPI client and symfony2. It is only meant to be used as a clientless app., (*2)

Code borrowed heavily from InoriTwitterAppBundle a great Twitter bundle and inspired by Harvest4Clients a, (*3)

Example usage

Example use-case for this bundle would be display Harvest data (from your project account) about clients, projects or tasks etc in your system., (*4)

Installation

With composer:

Add this bundle and the HaPi package to your composer.json:, (*5)

// composer.json
{
    // ...
    require: {
        // ...
        "mattvick/harvest-app-bundle": "master"
    }
    // ...
    "repositories": [
        // ...
        {
            "type": "package",
            "package": {
                "name": "mdbitz/hapi",
                "version": "1.1.1",
                "dist": {
                    "url": "http://labs.mdbitz.com/wp-content/uploads/2010/10/HaPi-1.1.1.zip",
                    "type": "zip"
                }
            }
        }
    ],
}

Open up your app/autoload.php file and add the HaPi HarvestAPI Autoloader:, (*6)

//app/autoload.php
// ...
require_once __DIR__.'/../vendor/mdbitz/hapi/HarvestAPI.php';
spl_autoload_register( array('HarvestAPI', 'autoload') );
// ...

This tells Symfony2 where it can locate your HarvestAPI class. Since HaPi Harvest API does not yet follow the PSR-0 Naming standards its autoloader has to be attached manually., (*7)

Add this bundle to your application's kernel:, (*8)

//app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Mattvick\HarvestAppBundle\MattvickHarvestAppBundle(),
    );
}

Configure the harvest_app service in your YAML configuration:, (*9)

#app/config/config.yml
mattvick_harvest_app:
    user:      xxxxxx  # this is your email address
    password:  xxxxxx
    account:   xxxxxx  # this is your Harvest subdomain (see below)

NB! The account is the Harvest subdomain you use to access Harvest, such as: https://subdomain.harvestapp.com/., (*10)

Now tell composer to download the bundle by running the command:, (*11)

$ php composer.phar update mattvick/harvest-app-bundle

Using HarvestApp

If the setup is done correctly, then you can start using HarvestApp like this:, (*12)

// ...
$api = $this->container->get('harvest_app')->getApi();

An example use in a controller is as follows:, (*13)

// ...
$api = $this->get('harvest_app')->getApi();

$result = $api->getClient(123456);
if ($result->isSuccess()) {
    $client = $result->data;
}

To use the advanced reporting functions of HarvestReports:, (*14)

// ...
$api = $this->container->get('harvest_app_reports')->getApi();

An example use in a controller is as follows:, (*15)

// ...
$api = $this->get('harvest_app_reports')->getApi();

$result = $api->getActiveProjects();
if ($result->isSuccess()) {
    $projects = $result->data;
}

See the HaPi Harvest API documentation for more examples., (*16)

The Versions

13/10 2012

dev-master

9999999-dev

Symfony2 wrapper around HaPi Harvest API client for app usage

  Sources   Download

MIT

The Requires

 

by Matthew Vickery

api harvest