husband, dad, steelers fan and software engineer

I am a strong believer that the power of the internet is best leveraged when it is used for funny memes, pictures of cats, and that really amazing video about Tom Brady’s balls. However, I feel that I need to break from my strong belief about the internet for a moment and instead bend it to my will and rant.

Recently while chatting with a friend I regurgitated a sentiment from a tweet I saw, or maybe it was on a blog I read or quite possibly a Podcast I heard. Honestly the source doesn’t matter, this is the internet and attribution died along with academic citations. Long live Wikipedia! I digress. So this sentiment was mine, despite having found it elsewhere. What was this profound sentiment you ask? Simply that while we have all this awesome technology that resembles the Science Fiction of my youth, I do not recall there ever being so many cords… Did you ever see someone charge Data? Or plug a tricorder into the wall? Where was Luke’s light saber docking station? At the time I was reflecting I considered this as a weakness of the evolution of technology. I believed that we had not yet achieved that synergistic point where real life and Science Fiction merged in an amazingly beautiful union where neither was distinguishable from one another.

Then I was driving today and I realized that if the evolution of humanity is determined by the survival of the fittest it’s actually those still yielding cords in their vehicles that will survive. It will be the heavily corded souls ruling the road that will define future generations. Which means Science Fiction is all a lie.

Bear with me while I explain. We are all worried about teen drivers (and some half brained adults like myself) texting while on the road with their mobile devices. This fear does not seem misplaced, especially when people are carrying devices so large that they must use two hands with them. Many states have even gone so far as to pass laws prohibiting using your mobile devices while in moving vehicles. As I’m sure you know, these laws are religiously followed and obeyed by all of man kind - at least any God-fearing Patriot. I postulate that texting while driving is hardly the thing we should fear most about today’s roads. It’s actually bluetooth!!! Years from now we will look back and realize that the rollout of bluetooth was actually a genocide stunting the growth of the population! There is nothing more perilous than to be in a moving vehicle whimsically believing in the dream that your car and some other device will communicate in perfect harmony. When this fails, and it always does, you find yourself speeding down a highway (or as in my case a far too narrow country road with steep ditches on either side) trying to reconcile why two devices which say they can talk to each other simply will not work! The rage builds up inside, you dismiss the heavily federally regulated dialog that says only passengers should pair devices in moving vehicles, and you fight the never-ending battle of bluetooth hell that rages all about the vehicle you reside in. And may God have mercy on your soul if there are more than one device involved in this awful union of technology.

Bluetooth will kill us. One by one we will succumb to stupidity on the road. Only the cord bearers will survive this awful twist of human evolution. Science fiction was all a lie. Wireless and charger-less devices have no basis in our technological future. They are simply a figment of a wonderful play of fantasy that is less likely to be realized than an ice queen who sings on mountain tops. Give up, just plug your damn device in.

Congratulations if you’ve made it this far. You are part of the few, the proud, those that can read more than 140 characters on the internet. Go buy yourself a beer!

Apr 7, 2015

LemonRestBundle 0.8.0 has been released. The theme for this version is compatibility. While several significant bugs have been fixed since the last release, the focus has been primarily on ensuring that the bundle is compatible with a wide range of versions of PHP, Symfony and Doctrine. Additionally the bundle now comes with support for MongoDB and better support for other implementations of Doctrine.

Compatibility with PHP

LemonRestBundle now supports PHP 5.3, 5.4, 5.5, 5.6. Additionally the primary ORM test suite passes when using Doctrine 2.5 on HHVM and HHVM nightlies. Tests are also actively being run against PHP 7, though compatibility will not be guaranteed until after it is stable.

Compatibility with Symfony

LemonRestBundle now supports Symfony versions 2.3, 2.4, 2.5 and 2.6. Additionally, preliminary support has been made for 2.7. While 2.7 is not currently running in Travis CI, if you use it in your projects it will work.

Compatibility with Doctrine ORM

LemonRestBundle now support Doctrine ORM 2.3, 2.4 and 2.5 In general it is recommended you use 2.5 whenever possible.

Compatibility with Doctrine MongoDB ODM

LemonRestBundle now works with Doctrine MongoDB ODM! There are tests specifically for the mongo implementation and they are running in TravisCI.

Except where indidcated, all of these versions and combinations of these versions are being tested against automatically in TravisCI. You can always check the builds out here.

Update to the latest version of LemonRestBundle and let me know what you think!

Work on LemonRestBundle continues, last night I merged in support for PATCH. This is an interesting beast because there are some strong opinions on the proper way to implement PATCH in a REST API. Initially I assumed I would just avoid it rather than subject myself to the judgment of poor implementation. However, the more I researched PATCH the more I realized that I wanted to add it, and furthermore the strong opinions were largely academic in nature. The JSON Patch specification is rather powerful but also complex, I've yet to find a consuming client that actually supports this standard. What I see a lot of is more akin to the JSON Merge Patch specification, and this is exactly what I've decided to add. Truthfully the bulk of the work in my implementation happens in JMS Serializer. I need to do more extensive testing on object nesting but the basic implementation works right now. One issue to keep in mind is the current setup requires you to specify the object id when in the PATCH request. I hope to fix this in the future, but for now that's the requirement.

I've also recently added the ability to customize the Criteria object for searches.  The Criteria object is basically a collection of the query parameters and it gets used by the ObjectManager to add filtering to the findBy() command used for making collections of a given resource. Out of a set of query parameters the default implementation separates out some data for limit, offset, order by and order direction and then provides those in a standard way to the ObjectManager. The limiting factor in the initial implementation is that you might not have liked the fields I was using for limit, offset, etc. Customizing the Criteria object gives you full control over how this is handled. You can read more about how to configure this in the bundle's documentation.

I've been experimenting with generating Swagger docs within my bundle. I would expect this to materialize in the next week or so.  The technical details are already available to generate the docs, it's the descriptive data that isn't there yet and I'm still evaluating the best way to make that possible. Ultimately I'd love to have the bundle help it's users generate documentation for their APIs, eliminating yet one more detail in the management of a REST API.

Last but not least there I think it's safe to expect support for versioning, again this will largely be driven off of JMS Serializer's version exclusion groups.

Work on the bundle continues to move forward. Several folks have made contributions, all of which I am really grateful for! If you have a suggestion, recommendation or spotted a bug of any sort please open an issue over on GitHub.

tl;dr You can try out LemonRestBundle with ng-admin here.

Last week I shared that I was working on a Symfony 2 bundle that would create REST end points from Doctrine entities. I've been continuing to work on that bundle, adding features and flexibility and I decided to re-evaluate the way I was demoing it. The truth is that I didn't want to sink a lot of time into writing a demo, but I also want to do a show more functionality than just pulling down some objects from and dumping them to a page. What I want is to show the full REST life cycle, getting, searching and saving objects to an api. Fortunately there's a really great tool out there that plugs into a REST api and does just that! It’s called ng-admin and it’s from the folks over at Marmelab.

For those that aren't familiar with ng-admin, it's a tool written using Angular and it allows you to easily wire up a "stock" UI for a REST API. Like my own project, it's opinionated and convention oriented. Quite honestly it's a pretty cool tool. So I’ve hooked it up to a symfony standard application with the LemonRestBundle and configured some entities to match Marmelab’s own demo. I also pulled the sample data down that Marmelab was using and stuck it in a sqlite database. The database resets every minute, but it’s enough time to create a post and edit some comments and see LemonRestBundle in action. The really cool part is when you take a look at the demo app’s GitHub repository and realize it took three Entity classes to make the whole thing happen.

I’ve deployed the demo over at OpenShift so you can take a look and try it out for yourself. You can also clone the demo app from GitHub, run composer.phar install and try it yourself!

Links to check out:

For a little while now I’ve been working on a bundle for Symfony to easily create REST apis for Doctrine entities. My goal was to be able to create a REST api with nothing more than a Doctrine entity and it’s metadata, including custom metadata from bundles like JMS Serializer. I wanted to invest very little time in the actual api part, and get to writing applications that used it. I’ve hit this wall before, and inevitably what happens is I make a valiant effort at rolling a REST api and then get distracted or bored and walk away leaving the project to rot.

Recently I was resurrecting an older project and wanting to do right by it and decided I could mask a lot of my database worts by leveraging some of Doctrine’s more advanced features. Specifically I added custom types to ensure I had good data structures, leveraged some lifecycle events and implemented Doctrine 2.5’s recent addition of Embeddables. I had also added a bunch of validation to my entities using Symfony’s Validation component, so they were well defined and could be validated easily with meaningful responses when things weren't right. I wound up with a clean set of objects that did what I wanted well, but there was one problem, I needed an api! Having been down this road before I wanted to solve my problem for the last time, or at the very least make the problem more interesting to solve.

Recently I have been playing with Knp’s JSON Schema bundle and this was in part my inspiration to make something that was magical. I don’t mean magical in the buzz word sense (okay, maybe I do). I mean magical in the highly opinionated, convention driven sort of way. My solution needed to just work(tm). The pieces were all there, and as I mentioned earlier the bulk of the tooling already existed, specifically great serialization, easy validation, reliable content negotiation and of course the graph traversal of Doctrine itself.  I just needed to get it all hooked into the request/response process of an api. Thus begot my very own REST bundle for Symfony 2.

Now hold up, I know what you’re thinking... Symfony already has a REALLY good REST bundle from Friends of Symfony, doesn’t it? This is very true! That is an excellent bundle, it’s high powered and very flexible. Mine is not. In fact it’s not even intended to be. If you want HATEOAS for example, FOSRestBundle is the right option for you. If you need to customize the POST/PUT processes or alter extensively the behavior of your GET actions, then FOSRestBundle is going to be a far better option for you. If you want to use Propel or Mongo (though that may come in the future for mine) or any other data source besides Doctrine ORM than FOSRestBundle is the better option for you. If you are using Doctrine ORM and want to write as little code as possible while getting some REST endpoints, than my bundle might be the better option for you.

Enough chatter, take a look at the fixtures included in my bundle and you’ll see some very simple examples of what sort of metadata driven modeling I had in mind for this project. I have a pretty extensive functional test that shows how the bundle works. I’ve also built a simple example application using this bundle that you can take a look at and see the bundle working. Well without further delay, I'm really happy to share with you LemonRestBundle, documentation included! Feedback is very welcome, feel free to drop me an email or shoot me a message on twitter.