asana logo

Using Asana API in Laravel/PHP

Recently I’ve started a new client project which uses API of a project management tool called Asana. So I decided to write up a short demo for anyone who wants to use it, it’s really simple.

With that, this could be a good example of a service having their own official PHP package, and how to use it.

First, here’s how Asana looks like. On a basic level, it’s just a list of tasks.

asana list

So my job here was to take the task list via Asana API into Laravel. So let’s do exactly that.

Step 1. Create Asana Token

To do that, go to Asana’s My Profile Settings and make a few clicks to generate token, here are a few screenshots:

Screen Shot 2018-06-12 at 5.03.48 PM
Screen Shot 2018-06-12 at 5.03.35 PM
Screen Shot 2018-06-12 at 5.05.07 PM

Step 2. Use Asana’s Package

Asana have their own official PHP package: Asana/php-asana. Notice that it’s not Laravel specific, it’s for any PHP called, in other words it’s framework-agnostic.

So we install it into our Laravel app:

And then inside of our Controller (or, I would recommend to create a separate AsanaService) we can do this:

That’s it. A simple example of using existing official package. You can also check the official documentation on other API methods, or how to use OAuth instead of the personal access token.

Want to generate Laravel adminpanel online?
You don't need any packages to do that!

Leave a Reply

Your email address will not be published. Required fields are marked *