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

CloudWays Blog:
Samantha Quiñones Shares Insights On APIs, Elasticsearch And R-Language Programming
Apr 18, 2016 @ 09:05:32

On the Cloudways blog they've posted another interview with a member of the PHP community. In this latest post they talk with Samantha Quiñones, a principal software engineer at AOL and user group organizer.

Samantha Quiñones is the principal software engineer at AOL, organizer of DC PHP user group and a speaker. She is a certified R-programmer with vast experience in developing REST APIs. In her interview with Cloudways she talks about the early years of her career, her experience as a speaker and in the end gives advice on who to follow in the PHP community.

In the interview Samantha answers questions about:

  • how she got started in her career as a developer
  • why she started speaking and where she'll be speaking
  • her experience as a security developer at Saint
  • what she enjoys doing when not programming

Finally, she makes a recommendation of someone to follow if you want to get involved in the wider PHP community or just want a good person to start with: Cal Evans.

tagged: cloudways interview samanthaquinones api rest elasticsearch rprogramming community

Link: http://www.cloudways.com/blog/samantha-quinones-interview/

TutsPlus.com:
WP REST API: Internals and Customization
Apr 14, 2016 @ 11:24:28

TutsPlus.com has posted the latest part of their series focusing on the WordPress REST API. In this new part of the series they look at some of the internals of the API code and the customizations you can make on the data returned.

In the previous part of the series, we learned about creating, updating, and deleting content remotely through the WP REST API. It allows us to create platform-independent applications that work seamlessly with a WordPress powered back-end, providing a rich experience to the user.

In the current part of the series, we will take a look at the internals of the WP REST API and how they work together to power the API. After that, we will learn to modify server responses for the default endpoints to include custom fields.

They walk you through a few different topics around the API including the internal classes that power it, how to modify the server and making custom fields editable. There's a bit of code involved when it comes to modifying the custom fields in the response and registering an editable field. The rest is mostly about configuration and what methods are doing what during the request.

tagged: wordpress tutorial wpapi api rest internals customization fields editable

Link: http://code.tutsplus.com/tutorials/wp-rest-api-internals-and-customization--cms-24945

Jeremy Curny:
Symfony 3 - REST API
Apr 04, 2016 @ 13:19:26

In this post to his site Jeremy Curny briefly walks you through the creation of a REST API using the Symfony 3 framework and several components/bundles to add in common functionality.

He includes the commands and dependencies you'll need to get the system set up:

  • Initialize the project
  • Install dependencies (including the FosRestBundle, JMSSerializerBundle and NelmioCorsBundle bundles)
  • Register bundles
  • Configure bundles
  • Making the first route

He ends with the command to run the built-in web server and be able to test out the result. The simple action he's created can then be called using a GET request on the default/index route with a 200 OK response with "hello world" content.

tagged: symfony3 symfony framework tutorial rest api project

Link: http://jeremycurny.com/2016/03/27/symfony3-rest-api/

Marko Pavlovic:
Restful Commander
Mar 23, 2016 @ 11:55:10

In this post to his site Marko Pavlovic talks about REST APIs, some of the non-CRUD (create, read, update, delete) operations that need to be performed and how the Command design pattern can help.

We’ve all been here: the data model has been designed, and we have the entities and relationships implemented. It is finally time to code up the business logic and we are faced with solving these problems: The actions we want to implement on a particular model are not part of the good old CRUD (Create, Read, Update, Delete) operations, and we need to make a lot of non-standard controller actions, and routes. [Also] the actions we want to implement do not belong to a any model, and we have to create a new controller just for the "API".

He gives a more concrete example to illustrate the problem using "sites", "visits" and a desire to add analytics functionality using each's data. He points out two common actions taken when something like this comes up: either new methods on the pre-existing controllers or possibly making a new controller to handle it. Instead he suggests using the Command pattern to handle requests themselves as self-contained items. This gathers all the logic needed in to one place and the Report instance can then be used as-is by the response that needs to render the results.

tagged: rest api command designpattern report site visit

Link: http://markonis.github.io/rest/api/design-patterns/2016/02/23/restful-commander.html

Gonzalo Ayuso:
Foreign Data Wrappers with PostgreSQL and PHP
Feb 22, 2016 @ 09:43:48

Gonzalo Ayuso has posted a quick tutorial to his site showing you how to work with Foreign Data Wrappers on your PostgreSQL database in PHP. If you're not familiar with the data wrappers functionality, you can find out more on the PostgreSQL wiki.

PostgreSQL is more than a relational database. It has many cool features. Today we’re going to play with Foreign Data Wrappers (FDW). The idea is crate a virtual table from an external datasource and use it like we use a traditional table.

He gives an example of a simple RESTful service with a Silex application serving up a set of user data (names). He then switches over to the PostgreSQL side and shows how to create the data wrapper and set up the mapping of it to the REST server's location. With that set up you can then select from the data returned as if it were a normal table with a slight caveat - filtering (like with where) must be done server side, not via the SQL statement.

tagged: postgresql tutorial foreigndatawrapper datawrapper database rest service

Link: http://gonzalo123.com/2016/02/22/foreign-data-wrappers-with-postgresql-and-php/

Noupe.com:
How Will REST API Affect WordPress Developers?
Feb 03, 2016 @ 10:48:31

On the Noupe.com site they've posted an article talking about the WordPress REST API that's been included by default in the project and how it will affect developers on the platform.

With the advent of WordPress 4.4 last year in December, we saw the inclusion of the first half of REST API in the WordPress Core, and the rest of it is expected to be with us in the upcoming major release of WordPress. [...] The community is abuzz with all talks about how important REST API will soon be for WordPress development, and how it is going to change the way developers code and interact with WP.

So, how is REST API going to affect the WordPress users and developers, and what exactly will we be able to accomplish using it?

In the article they talk about the impact that the API will have on the "rise of Javascript" in the WordPress application and the role PHP could play in it all. They also talk about cross-platform integrations the REST API makes possible, the Calypso interface that was recently announced and how it opens up a new world of mobile application possibilities.

tagged: wordpress api rest impact developers javascript crossplatform calypso mobile

Link: http://www.noupe.com/development/cms/how-will-rest-api-affect-wordpress-developers.html

NetTuts.com:
WP REST API: Setting Up and Using OAuth 1.0a Authentication
Jan 15, 2016 @ 10:54:12

The NetTuts.com site has a new tutorial posted showing you how to work with the authentication of the WordPress REST API and using its OAuth 1.0a handling. This is part three in their series of tutorials introducing the WordPress REST API.

In the previous part of the series, we set up basic HTTP authentication on the server by installing the plugin available on GitHub by the WP REST API team. [...] For using authentication on production servers, there needs to be a more secure way of sending authenticated requests without risking exposing the login credentials. Thanks to the OAuth authentication method, those requests can be sent without exposing the username and the password in an unsafe manner.

In the current part of the series, we will learn to set up and use the OAuth authentication method to be used with the WP REST API plugin.

They start the tutorial with a brief look at what OAuth is and how it's used to authenticate the end user/client/software/etc. They then walk through the flow of a simple OAuth-based authentication system and the pieces that make it up. Then the article gets into how to install the plugin for your WordPress instance and activate it from the command line. They show how to test that it's enabled and how to use a command line client to create tokens you can then use to access the API in your own clients.

tagged: wordpress tutorial wpapi api rest oauth authentication series part3

Link: http://code.tutsplus.com/tutorials/wp-rest-api-setting-up-and-using-oauth-10a-authentication--cms-24797

NetTuts.com:
WP REST API: Setting Up and Using Basic Authentication
Jan 08, 2016 @ 11:37:58

On the NetTuts.com site there's a tutorial posted showing you how to set up and use basic authentication in the WordPress REST API. This is part two in their series introducing the WordPress REST API.

In the introductory part of this series, we had a quick refresher on REST architecture and how it can help us create better applications. [...] In the current part of the series, we will set up a basic authentication protocol on the server to send authenticated requests to perform various tasks through the REST API.

They talk about the methods that are available for authentication and how to configure your server and WordPress instance to use it. From there they show how to make authenticated requests to the API using various tools:

  • Postman
  • a Javascript framework (jQuery)
  • the command line via curl
  • using the WP HTTP API

Example code and screenshots are provided for each (where appropriate) helping to ensure you're up and working quickly.

tagged: wordpress rest api tutorial authentication basic postman javascript commandline

Link: http://code.tutsplus.com/tutorials/wp-rest-api-setting-up-and-using-basic-authentication--cms-24762

IntelligentBee.com:
Getting Started with Building APIs in Symfony2
Nov 09, 2015 @ 13:44:28

The IntelligentBee.com site has a "quickstart" kind of tutorial for those wanting to use Symfony 2 to build an API-based application. In this tutorial they walk you through a few step process to create the application and a few actions to get the basics working.

Hello all you Interwebs friends! While we’re passing through the shallow mists of time, REST is becoming more and more of a universal standard when building web applications. That said, here’s a very brief tutorial on how to get started with building APIs in Symfony2.

They make use of two other libraries, the FoSUserBundle, JMSSerializerBundle and Doctrine, to handle some of the low level user management and database functionality. They show you how to:

  • Generate a new bundle
  • Set up API versioning
  • Install the FoSUserBundle and JMSSerializerBundle
  • Configure the application's REST interface
  • Set up the routing to get things to the right place

Code is also included to show the creation of "get user" and "get users" actions along with a simple form and "add user" endpoints to allow new users to register. Wrapping the post up, he includes the code for the other pieces of the CRUD operations, the "edit user" and "delete user" methods.

tagged: api symfony2 tutorial introduction rest user management bundle versioning

Link: http://intelligentbee.com/blog/2015/11/03/getting-started-with-building-apis-in-symfony2/

Michael Mikowski:
RESTful APIs, the big lie
Sep 09, 2015 @ 11:19:31

Michael Mikowski has a post to his site that suggests that a RESTful API is a big lie and that the concept should "rest in piece" and be replaced with something he calls a "JSON-pure API".

If you have read an internet developer resume or job posting in the past 10 years, then you might be forgiven if you think that RESTful APIs are gifts bestowed from the heavens by The One True Web Developer Deity. RESTful APIs are everywhere. Even the marketing folks are pushing them in sales material intended for CEOs and Human Resources-type folks. So how good of an idea are RESTful APIs really?

He starts with a look at where the concepts for a RESTful API originally came from and defines some of the most common concepts around them (verbs, request/response, etc). He then suggests that they're "pretty awful" and lists some of the larger problems he sees with them:

  • Problem #1: There is little agreement on what a RESTful API is
  • Problem #2: The REST vocabulary is not fully supported
  • Problem #3: The REST vocabulary is not rich enough for APIs
  • Problem #4: RESTful APIs are very hard to debug
  • Problem #5: RESTful APIs are usually tied to HTTP

He suggests that the way to move forward is to migrate to the "JSON-pure API" methodology, fixing most of the problems he listed. He describes this kind of API and how it simplifies the entire process and makes it "more reliable, easier to use, easier to port, and easier to debug."

tagged: restful rest api jsonpure problem lie opinion

Link: http://mmikowski.github.io/the_lie/