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

Cal Evans:
Managing the Verbosity of symfony’s Command Object With a Trait
Jul 15, 2013 @ 17:29:39

In this new post to his site Cal Evans goes through a simple application he's created using the Symfony Command component and some of his gotchas along the way. He shows how, using a trait, he was able to control the output of the command more effectively.

Recently I came up with a project I needed to build. Honestly, it’s one of those “not useful to anyone but me” kind of projects. I decided though that while I was at it, I wanted to learn something new. Since I’ve been a die-hard Zend guy since Zend Framework was 0.2, and more recently a Silex believer, I thought I would drop down a level form Silex and dig into symfony itself. This project is strictly a command line project. No API, no web interface, just a command and a few switches. Digging around I found SymfonyComponentConsoleCommandCommand so I decided to give it a try.

He goes through some of the work he did to pull in the needed packages and create his first command. He creates a "writeln" method to output to the console that contains his check for the verbosity level of the current command options (like "quiet" or "verbose"). He introduces the trait to add some additional handling to this output, making it easier to just drop in the "writeln" functionality in any command of his choosing.

tagged: verbosity trait symfony command silex writeln

Link: http://blog.calevans.com/2013/07/10/managing-the-verbosity-of-symfonys-command-object-with-a-trait

Lorna Mitchell:
Are Subqueries RESTful?
Jun 13, 2013 @ 15:41:14

In this new post to her site Lorna Mitchell tries to help answer a question she got on Twitter about "subqueries" in REST API calls. In this case, a subquery is requesting just a subset of the data from a resource.

REST is all about representations of resources. They might come in different formats, and they might appear at their own URI as well as in one or more collections, but essentially you just get a representation of a thing. This is great, apart from when it isn't. [...] There are a couple of tactics that I deploy each time I need to solve one of these problems, but they all revolve around remodelling the resource structure. Just as we sometimes move fields around for database design or normalisation, we can do exactly the same with a RESTful service to make the resulting output make more sense to consumers.

She talks about one method that lets the consumer change the "verbosity" of the response and another that splits these pieces out into separate sub-resources for each section. She suggests a third option as well, the nesting of likely data - that is related data the user might most likely want along with what they requested.

tagged: rest api subquery verbosity subresource likely data

Link: http://www.lornajane.net/posts/2013/are-subqueries-restful


Trending Topics: