mattvick / harvest-app-bundle
围绕 HaPi Harvest API 客户端的应用程序使用的 Symfony2 包装器
Requires
- php: >=5.3.2
- mdbitz/hapi: *
- symfony/framework-bundle: 2.*
This package is not auto-updated.
Last update: 2024-09-28 12:56:43 UTC
README
为应用程序使用封装了 HaPi Harvest API 客户端。
MattvickHarvestAppBundle 是一个简单的代理包,位于 HaPi HarvestAPI 客户端和 symfony2 之间。它仅用于无客户端的应用程序。
从 InoriTwitterAppBundle 借用了大量代码,这是一个优秀的 Twitter 包,并受到 Harvest4Clients 的启发
示例用法
此包的示例用例可能是显示 Harvest 数据(来自您的项目帐户)关于客户、项目或任务等。
安装
使用 composer
将此包和 HaPi 包添加到您的 composer.json 文件中
// 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"
}
}
}
],
}
打开您的 app/autoload.php
文件,并添加 HaPi HarvestAPI 自动加载器
//app/autoload.php
// ...
require_once __DIR__.'/../vendor/mdbitz/hapi/HarvestAPI.php';
spl_autoload_register( array('HarvestAPI', 'autoload') );
// ...
这告诉 Symfony2 可以在何处找到您的 HarvestAPI
类。由于 HaPi Harvest API 还未遵循 PSR-0 命名标准,因此其自动加载器必须手动附加。
将此包添加到您的应用程序内核中
//app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Mattvick\HarvestAppBundle\MattvickHarvestAppBundle(),
);
}
在您的 YAML 配置中配置 harvest_app
服务
#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)
注意! account
是您用于访问 Harvest 的 Harvest 子域名,例如:https://subdomain.harvestapp.com/。
现在通过运行以下命令让 composer 下载此包
$ php composer.phar update mattvick/harvest-app-bundle
使用 HarvestApp
如果设置正确,则可以像这样开始使用 HarvestApp
// ...
$api = $this->container->get('harvest_app')->getApi();
以下是一个控制器中的示例用法
// ...
$api = $this->get('harvest_app')->getApi();
$result = $api->getClient(123456);
if ($result->isSuccess()) {
$client = $result->data;
}
要使用 HarvestReports 的高级报告功能
// ...
$api = $this->container->get('harvest_app_reports')->getApi();
以下是一个控制器中的示例用法
// ...
$api = $this->get('harvest_app_reports')->getApi();
$result = $api->getActiveProjects();
if ($result->isSuccess()) {
$projects = $result->data;
}
有关更多示例,请参阅 HaPi Harvest API 文档。