2017 © Pedro Peláez
 

yii2-extension yii2-asana

Yii2 component for integration with asana via REST API

image

marshmeloo/yii2-asana

Yii2 component for integration with asana via REST API

  • Saturday, October 18, 2014
  • by marshmeloo
  • Repository
  • 1 Watchers
  • 1 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yii2 Asana

Yii2 Asana is a component for Yii2 framework designed for integration with Asana CMS via XML-RPC API., (*1)

This component is built on top of Asana XML-RPC PHP Client by Hieu Le Trung., (*2)

Latest Stable Version Build Status Code Climate Scrutinizer Code Quality Version Eye License, (*3)

Requirements

  • Yii 2.0 (dev-master)
  • PHP 5.4
  • PHP extension XML-RPC

Note: This extension mandatorily requires Yii Framework 2. The framework is under active development and the first stable release of Yii 2 is expected in early 2014., (*4)

Installation

The preferred way to install this extension is through Composer., (*5)

Either run, (*6)

php composer.phar require marshmeloo/yii2-Asana "dev-master", (*7)

or add, (*8)

"marshmeloo/yii2-Asana": "dev-master", (*9)

to the require section of your composer.json file., (*10)

Usage

Component creation

In order to use this extension, first thing you need to do is to create a blog (you can change the name if you want) component and configure it. Here is the example of minimal configuration (in your config/main.php):, (*11)

    'components' => [
        ...
        'blog' => [
            'class' => '\marshmeloo\yii2wp\Asana',
            'endpoint' => 'http://example.com/xmlrpc.php',
            'username' => 'demo',
            'password' => 'demo'
        ]
        ...
    ]

First API request

When component is configured, you can start making requests to your Asana site., (*12)

For example, get ten latest published posts. Select guid, post_title and post_content fields only:, (*13)

    $blogPosts = Yii::$app->blog->getPosts([
        'post_status' => 'publish',
        'number' => 10
    ], ['guid', 'post_title', 'post_content']);

Or create a new post with title "New post" and content "Hello world!":, (*14)

    $postID = Yii::$app->blog->newPost('New post', 'Hello world!');

Caching request results

Making API calls to an external application means delays. If you don't want your users to wait for a Asana response each time, caching is a right thing to do:, (*15)

    // The user profile will be fetched from cache if available.
    // If not, the query will be made against XML-RPC API and cached for use next time.
    $profile = Yii::$app->blog->cache(function (Asana $blog) {
        return $blog->getProfile();
    });

In case, if you need something more complex, you can disable caching for some requests:, (*16)

    $blogPosts = Yii::$app->blog->cache(function (Asana $blog) {

        // ... queries that use query cache ...

        return $blog->noCache(function (Asana $blog) {
            // this query will not use query cache
            return $blog->getPosts();
        });
    });

Caching will work for data retrieval queries only. Queries that create, update or delete records will not use caching component., (*17)

Configuration parameters

$endpoint

string Asana XML-RPC API endpoint URL., (*18)

$username

string Asana authentication username., (*19)

Please note, that any actions made by XML-RPC will be made on behalf of this user., (*20)

$password

string Asana authentication password., (*21)

$proxyConfig

array Proxy server configuration., (*22)

This configuration array should follow the following format:, (*23)

  • proxy_ip: the ip of the proxy server (WITHOUT port)
  • proxy_port: the port of the proxy server
  • proxy_user: the username for proxy authorization
  • proxy_pass: the password for proxy authorization
  • proxy_mode: value for CURLOPT_PROXYAUTH option (default to CURLAUTH_BASIC)

Empty array means that no proxy should be used., (*24)

Default value: []., (*25)

$authConfig

array Server HTTP authentication configuration., (*26)

This configuration array should follow the following format:, (*27)

  • auth_user: the username for server authentication
  • auth_pass: the password for server authentication
  • auth_mode: value for CURLOPT_HTTPAUTH option (default to CURLAUTH_BASIC)

Empty array means that no HTTP authentication should be used., (*28)

Default value: []., (*29)

$catchExceptions

boolean Whether to catch exceptions thrown by Asana API, pass them to the log and return default value, or transmit them further along the call chain., (*30)

Default value: true., (*31)

$enableQueryCache

boolean Whether to enable query caching., (*32)

Default value: true., (*33)

$queryCacheDuration

integer The default number of seconds that query results can remain valid in cache., (*34)

Use 0 to indicate that the cached data will never expire., (*35)

Default value: 3600., (*36)

$queryCache

Cache|string The cache object or the ID of the cache application component that is used for query caching., (*37)

Default value: 'cache'., (*38)

List of available methods

The full list of available methods can be found in Asana XML-RPC PHP Client Class Reference., (*39)

Please note, that all those methods are throwing an exceptions in case of any errors. While this extension is configured (by default), in case of errors, to return an empty array for any data retrial methods and false for any create, update or delete methods. Please see $catchExceptions configuration option for details., (*40)

Errors logging

There are a lot of things that can go wrong (network problems, wrong Asana user permissions, etc.). If $catchExceptions configuration option is set to true (default value), this extension will catch them and pass to marshmeloo\yii2wp\Asana::* logging category., (*41)

In order to see them, you can configure your Yii2 log component to something similar to this:, (*42)

    'components' => [
        ...
        'log' => [
            'targets' => [
                'file' => [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error'],
                    'categories' => ['marshmeloo\yii2wp\Asana::*'],
                ],
            ],
        ],
        ...
    ]

Report

License

yii2-Asana is released under the MIT License. See the bundled LICENSE.md for details., (*43)

Resources

The Versions

18/10 2014

dev-master

9999999-dev https://github.com/marshmeloo/yii2-asana

Yii2 component for integration with asana via REST API

  Sources   Download

Gaboli

The Requires

  • php >=5.4.0

 

by Vineet Kharwar

yii2 yii integration asana