News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Best Practices REST API from Scratch - Implementation
July 24, 2014 @ 13:11:22

PHPMaster.com has posted the second part of their best practices in REST APIs series with this new post focusing more on the implementation part of things.

We ended the first part of this tutorial with all the basic layers of our API in place. We have our server setup, authentication system, JSON input/output, error management and a couple of dummy routes. But, most importantly, we wrote the README file that defines resources and actions. Now it's time to deal with these resources.

They move on and add more functionality for creating (POST) and updating (PUT/PATCH) contacts in the system. They also show how to list contacts and add in some search handling allowing for sorting and returning only certain data. There's also some code for pagination handling, locating a single contact record, basic caching and simple rate limiting.

0 comments voice your opinion now!
rest bestpractices api tutorial implementation contacts

Link: http://www.sitepoint.com/best-practices-rest-api-scratch-implementation/

SitePoint PHP Blog:
Best Practices REST API from Scratch - Introduction
July 22, 2014 @ 09:39:12

The SitePoint PHP blog has posted the second part of their series looking at building up a REST API "from scratch". In this latest post Vita Tardia introduces some of the basic topics and the best practices that are around their use.

The current internet ecosystem has literally been invaded by APIs, and for good reasons. By using third party APIs in your products or services, you have access to a ton of useful features - such as authentication or storage services - that can benefit both you and your users. By exposing your own API, your application becomes "part of the mix" and will be used in ways you've never thought before… if you do it the right way, obviously. In this two part series I'll show you how to create a RESTful API layer for your PHP applications, using a collection of real world best practices.

He talks about how a REST API is a "user interface for developers" and the actions the different verbs could take on the same endpoints (PUT, POST, GET, etc). He uses the Slim framework in his examples and helps you get an instance all set up and working. He includes a bit about getting SSL/HTTPS up and running for all requests to the site too. From there he gets into the bootstrapping of the application and the first version of controller handling. He also includes code examples touching on JSON handling, authentication and good error handling.

0 comments voice your opinion now!
tutorial rest api introduction slimframework bestpractices

Link: http://www.sitepoint.com/best-practices-rest-api-scratch-introduction/

SitePoint PHP Blog:
Paginating Real-Time Data with Cursor Based Pagination
July 11, 2014 @ 11:52:13

On the SitePoint PHP blog today a new tutorial has been posted introducing you to cursor-based pagination of real-time data, showing the results and allowing for easy click-through functionality.

Pagination is a technique for breaking large record sets into smaller portions called pages. As a developer, you should be familiar with implementing pagination, but implementing pagination for real time data can become tricky even for experienced developers. In this tutorial, we are going to discuss the practical use cases and solutions for real time data pagination and cursor based pagination.

He uses results from the Twitter and Facebook APIs in his examples, grabbing tweets matching the search term "php". He briefly explains some of the issues with real-time pagination and how it compares with standard pagination techniques. He uses the "after" and "before" functionality of each API to only pull the data needed, not the entire list of latest posts. This is added to a list in order and shown when the user view is refreshed. He includes the code for implementing the cursor-based handling and how to echo the results back out to a view.

0 comments voice your opinion now!
cursor pagination twitter facebook api tutorial realtime

Link: http://www.sitepoint.com/paginating-real-time-data-cursor-based-pagination/

Master Zend Framework:
How to view an Instagram Photo Stream in Zend Framework 2
July 09, 2014 @ 10:53:59

On the Master Zend Framework site Matthew Setter has a new tutorial showing how to pull in Instagram photo feeds in a Zend Framework 2 application via their on developer functionality.

In today's tutorial, we're going to learn how to retrieve and display an Instagram photo stream in Zend Framework 2. We're going to cover the essentials of adding the libraries we'll need to composer.json, handling authentication and then retrieving and displaying our photo stream in a controller action. We'll be doing all of this by using composer to create a new Zend Framework 2 project, based on the ZF2 Skeleton App project and then add a new controller and action which will handle the work involved.

The tutorial uses a basic skeleton application and a PHP Instagram library to make the connection to their API. He shows you how to register your application with Instagram and set up the OAuth configuration to handle the authorization process. He walks you through the creation of the controller, setup of session support and the creation of a "photosAction" to view the results of the photo feed pull. He includes a screenshot of what the end result should look like with it all up and working.

0 comments voice your opinion now!
zendframework2 tutorial instagram photo feed api

Link: http://www.masterzendframework.com/api/view-instagram-photo-stream

WebLessons.info:
Login with LinkedIn
June 25, 2014 @ 10:47:16

The WebLessons.info site has a new tutorial posted showing you how to use the LinkedIn authentication handling to allow your users to log in with their own account information.

LinkedIn is a business-oriented social networking service. It is mainly used for professional networking. So if you are having an application or website that serves working professionals then its very important for you to implement login with LinkedIn in your application. By this way you can able to access the data of your users like email, work history, education etc. So now let's dive into the coding part.

They walk you through the various steps, providing screenshots or code where applicable:

  • Creating a LinkedIn Application
  • Get the API Key and Secret Key
  • Create the database and set up the PHP configuration to connect
  • finally, the PHP code for the login form and making the request to LinkedIn

A live demo can be found here (but if you're paranoid about your credentials, I wouldn't use it) and you can download all files included in the tutorial.

0 comments voice your opinion now!
linkedin login tutorial application api key secret

Link: http://weblessons.info/2014/06/25/login-with-linkedin-tutorial-php/

SitePoint PHP Blog:
Google's BigQuery Provides Free Access to GDELT
June 03, 2014 @ 10:19:31

In this recent post to the SitePoint PHP blog Bruno Skvorc points out a recent announcement from Google that the GDELT database information is now available via their BigQuery functionality.

The Global Database of Events, Language and Tone is one of the largest datasets on the planet. It is the quantitative database of human society, relying on thousands of news sources from every corner of the globe dating back to 1979. [...] Google BigQuery, "Google's powerful cloud-based analytical database service" is, basically, the world's fastest SQL engine, and it's completely free for any and all uses of GDELT. Due to the sheer power of BigQuery, you can get results on GDELT queries in near real-time and any permutation of fields and values you can think of won't be enough to bog it down to a halt - unless you really mess things up and go against the grain.

He goes on to describe the GDELT database and what kind of information it contains. He also includes an example query and the kind of data it returns (screenshot). He also links to a PHP-based library that you can install via Composer and use API keys to access their search endpoints.

0 comments voice your opinion now!
gdelt database bigquery access library sdk api

Link: http://www.sitepoint.com/googles-bigquery-provides-free-access-gdelt/

Joshua Thijssen:
Throttle your API calls RateLimitBundle
May 29, 2014 @ 09:02:51

In his latest post Joshua Thijssen introduces a new tool he's created to help Symfony2-based APIs handle rate limiting relatively easily: the RateLimit Bundle. The project was recently created as a part of some work he's been doing on the TechAnalyze service.

Too many times third party applications will be polling your API when they don't really need too, and maybe you can lighten the load a bit with some heavy-duty caching, but in essence you want that every API call made matters. [...] Most of our calls are pretty lightweight, but some of them aren't, nor are they easily cacheable. This is why we are limiting the number of calls each client can make to the API. But it wouldn't be fair to just limit the number of calls in general.

[...] Our platform is written in PHP, based on the Symfony2 framework. There are many different bundles available for symfony2, all adding new functionality, but somehow we couldn't find a (good) bundle for throttling our API. But after a search, we found a gist by Ruud Kamphuis, which pretty much does what we need. So we decided to set up a similar bundle, and added some flexibility in its usage.

The RateLimitBundle allows you to add a "@ratelimit" annotation directly to the controller or action in the application and adds remaining allowed calls to the response headers. The mentions some drawbacks to the bundle like a dependency on redis and how it figures out "distinct calls" to the API. He also breaks it down into the functional pieces and talks about how each one works and where it fits into the overall functionality.

0 comments voice your opinion now!
ratelimitbundle symfony2 api ratelimit throttle

Link: https://www.adayinthelifeof.nl/2014/05/28/throttle-your-api-calls-ratelimitbundle

Dutch Web Alliance:
Using Varnish with ESI for a REST API
May 08, 2014 @ 10:23:35

In the latest post to the Dutch Web Alliance blog Bas de Nooijer looks at a handy use of ESI in Varnish as a part of the output for a REST API. ESI (Edge Side Includes) let you handle the caching and reuse of fragments of the output from your application and define different caching rules/techniques for each.

For a project I'm currently working on we are implementing a REST API. Performance for this API is critical, so amongst some other solutions Varnish is used. This was done with minimal effort, as the API already had the correct caching headers. There was a noticeable improvement, however I had the feeling this could be improved much more. I realised I can basically compare our REST API to any website, it uses HTTP in the same way. The main diffence is the content being JSON instead of HTML. Just like most websites, our API composes content in many different ways, for instance 'standalone' resources, collections of resources or embedded resources. In a website this would be a clear use case for ESI, so why not use it in our API?

He starts off by asking the question "why use ESI in an API" and compares the ESI method to the more traditional caching rules and handling. He includes two diagrams showing the flow of each handling type along with a brief description of how it would extract and combine the data. With the background out of the way, he gets into the code. He shows how to enable JSON caching in Varnish and the JSON tag information you'll need to include to tell Varnish to do its job.

0 comments voice your opinion now!
varnish rest api tutorial cache esi edge side include

Link: https://dutchweballiance.nl/techblog/using-varnish-with-esi-for-a-rest-api

/Dev/Hell Podcast:
Episode 44 Gorf Fever
May 06, 2014 @ 12:09:44

The /Dev/Hell podcast, hosted by PHP community members Ed Finkler and Chris Hartjes, has released its latest episode - Episode #44 - Gorf Fever.

This weeks brings us a new guest and a new sponsor! Paddy Foran is an old friend of Chris and Ed's who makes his first appearance on the show, talking about the Go programming language, software architecture, open source projects, and his new book "Your API is Bad." We also welcome new sponsor Roave!

There's also mentions of a few other topics including Go, 2cloud and, of course, Gorf. You can listen to this latest episode either through the in-page player, by downloading the mp3 directly or by subscribing to their feed.

0 comments voice your opinion now!
devhell podcast ep44 gorf paddyforan api book

Link: http://devhell.info/post/2014-05-04/gorf-fever/

SitePoint PHP Blog:
How to Speed Up Your App's API Consumption
April 11, 2014 @ 10:51:23

The SitePoint PHP blog has some advice posted today from Jacek Barecki about how you can speed up your use of other APIs with a few performance increasing tips.

In the process of creating a PHP application you may come to a point when keeping it isolated from remote resources or services may become a barrier in its development. To move along with the project you may employ different API services to fetch remote data, connect with user accounts on other websites or transform resources shared by your application. [...] But using APIs in an incorrect way can quickly lead to performance issues and lengthen the execution time of your script. If you're looking for a way to avoid it, consider implementing some of the solutions described in the article.

He recommends four things you can think about doing to help make the most effective use of these services:

  • Make multiple requests at a time
  • Separate API calls from the app main flow
  • Build a smart cache engine
  • Master the API documentation
0 comments voice your opinion now!
api performance recommendation tips usage

Link: http://www.sitepoint.com/speed-apps-api-consumption/


Community Events





Don't see your event here?
Let us know!


release framework podcast series code community introduction developer install testing configure unittest threedevsandamaybe wordpress language interview list opinion library laravel

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework