Announcement: New PHP client available

Answered

Comments

11 comments

  • Patrick Steil

    Andreas, so what about our existing code, can we integrate this new API into our app without having to rewrite what we have and slowly migrate, or do we have to go ahead and migrate our entire app to use this new structure?

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Hi Patrick,

    You can sort-of slowly migrate. Meaning that there are some things you must change all at once, and others you can do step-by-step.

    Changes you must make

    Whenever you make an API call the syntax has changes. You are no longer passing around a singleton API object. You can now make API calls directly on the classes. So $api->task->get(123); becomes PodioTask::get(123); While boring, these changes are easy to make.

    In addition some method names changed. I did this to get consistency across the different areas and to avoid redundant naming. So $api->spaces->getTopSpaces() became PodioSpace::get_top()

    Changes you can make gradually

    More complicated for you is that the return values are now proper objects instead of JSON arrays. You will love this in the future, but the migration might be a little annoying.

    For example when you get an item the item title is no longer in $item['title'] it is in $item->title. This of course is more annoying with the nested structured. The author's name of the item is no longer in $item['initial_revision']['created_by']['name'] but in $item->initial_revision->created_by->name

    Going forward you will get a ton of benefits of the new structure as your code will be much easier to maintain.

    However! The old structure is still available if you want it. You can access the old-style JSON array in the 'attributes' property. So you can still do $item->['attributes']['title']. This way you can change things over gradually by doing something like this

    $item = PodioItem::get(123);

    $item = $item->attributes;

    // Much old code below will work without changes

    // Nested structures will still needs to be massaged a bit 

    Does that make sense?

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    PS. the old client is still available at https://github.com/podio/podio-php/zipball/v2 if you need to compare but I will not be spending any time updating it.

    0
    Comment actions Permalink
  • Patrick Steil

    Great, thanks Andreas!

    Are there any new API calls added in this version?

    Do you have a summary of all the API name changes documented yet?  

    Thanks!

    Patrick Steil

    http://www.podiotools.com 

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    I added almost all missing api calls. The ones I didn't add are in fringe areas of the API. Like Bulletin, Connections etc. If someone needs those I'll add them in, but I highly doubt anyone does. All the important things that were missing are now available (like Views).

    I don't have a summary of the names that changed. It was all manual labor and I didn't keep track while I was doing it.

    0
    Comment actions Permalink
  • Patrick Steil

    Ok, that's cool.... 

    When will you have an actual doc available for this version?

    Patrick Steil

    http://www.podiotools.com

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    There's already way more documentation for this version than the previous one. :)

    All the code examples on the developer website have been updated and in addition there are now a ton more examples in the download itself (look in the 'examples' folder). If you're looking for something specific feel free to create a question in this forum. :)

    0
    Comment actions Permalink
  • Patrick Steil

    Oh, sweet, thanks... sorry hadn't realized that!  :)

    Is the V2 documentation still available?  Please leave that up somewhere for a while... :)

    Patrick Steil

    http://www.podiotools.com

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    The code examples on the developer website are gone, if you need something specific I can find them for you. Fortunately the function arguments are the same so when you read the tutorial for dealing with Items you the values you pass to the functions are the same.

    The old README (which had the most information anyway) is still available in the download for the old version in my previous reply. :)

    0
    Comment actions Permalink
  • Peter van den Broek

    Dear Andreas,

    Thanks for the API, I think I'm missing an api call. To join a space. It was there in the previous version under SpaceMember, but I can't find it anymore now.

    I think you should add this to PodioSpaceMember.php

    /**

    * @see https://developers.podio.com/doc/space-members/join-space-1927286

    */

    public static function join($space_id) {

      return Podio::post("/space/{$space_id}/join");

    }

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk