VGTech is a blog where the developers and devops of Norways most visited website share code and tricks of the trade… Read more



Are you brilliant? We're hiring. Read more

Swagger docs in ZF2 with examples – Part 1: Setup and annotations

PHP

So everyone is building APIs now – parsing and outputting JSON is not that hard. Some people even build truly RESTful APIs, or something not to far from that.

Before, when building APIs was about SOAP with XML schemas and WSDL specifications, people spent so much time building their APIs that they had the time to think. Now, building an API is so easy and fast that the documentation is often suffering. Either because not much documentation is written in the first place, or because the API is evolving and nobody takes the time to update the documentation.

Swagger is a popular project providing auto generated API docs based on a service specification. This spec is based on annotation comments in the controllers and models, giving the developer a fairly easy, and close to the code way of keeping the API docs up to date.

In this two-part article on Swagger I will try to cover what you need to get your API docs up and running with Swagger + Swagger UI in ZF2. (more…)


VG+ 2.0: From Native to Hybrid App.

Android

VG+ is VG’s premium subscription based digital product and VG’s third editorial product, it consists of the best content from the printed VG newspaper with the best content from VG’s free news site www.vg.no. Context aware content tailor made for each platform ensures the ideal reading experience per device. The user can quickly and easily gain news insight on their mobile while enjoying a more immersive experience on the iPad.

 

The first version of VG+ was released in 2011 as an iPad app. It was a native application that won multiple awards including the ‘Best iPad Newspaper in the world’ at the WAN IFRA Cross Media Awards in 2011.

In 2013 we ditched our native apps and created a new set of VG+ Hybrid Apps (Android, iPhone and iPad). The goal was to combine the best of web technology with the best of native technology. We also created a new set of editorial tools that are tailor made to the needs of our editorial team and to creating interactive and instantly available content for mobile devices.

So why did we scrap the native apps and build hybrid apps?

(more…)


Building your own PaaS

DevOps

In this series, I’ll go through installing, using and extending Openshift Origin, a Platform as a Service (PaaS), developed by RedHat. Check it out at https://github.com/openshift

What is Openshift?

In short, Openshift consists of two things: A broker, and a node. (or two brokers for redundancy and hundred nodes for scaling) Each can run on whatever; baremetal, vmware, ec2…..

The management is done on the brokers. It controls the automation and orchestration of the nodes.

The user created applications runs on the nodes. You can install broker and node on the same host, but I wouldn’t recommend it as You’ll get in trouble if your node gets too much traffic.

On the nodes the applications are separated into “gears”. These are SElinux hardened containers which are given a set of hardware resources(ram,cpu,disk) though linux cgroups.

(more…)


Generating code coverage of Behat tests

PHP

Yes, I know, it sounds silly, but bear with me.

The nature of acceptance tests is not really to tests units of code, but to assure that the behavior of your application meets a certain set of criteria (Behat Scenarios).

When your applications grow over time, code coverage can be a nice tool to help you pinpoint where you need to add more tests. In a perfect world tests are added while implementing new features so that your applications are always fully tested, but that isn’t always as easy as it sounds.

This post is a follow-up to Using PHP’s built-in web server in Behat tests that was published some months back, so if you haven’t read that one yet make sure to do so before continuing. If you are not familiar with Behat I suggest you have a look at the quick intro guide as well.

(more…)


Varnish + requests with no Content-Length header

DevOps

HTTP 1.1 introduced the concept of chunked transfer encoding. This (among other things) enables us to send a request without knowing how large the content is going to be at the time we start the request.

An example usage would be where you generate content on-the-fly. You could potentially send chunks of a video-stream while you are recording or dynamically alter (compress, parse or similar) content from one source and incrementally send chunks to the server. (more…)


Varnish + HTTP Cache: An intro guide for web developers – Part 1

DevOps

Varnish, the web application accelerator:

varnish

Varnish development was initiated as a project within VG as a direct response to increasing demand hitting our servers hard. Existing caching systems were simply not fast or flexible enough to deal with VGs needs; and so Varnish was born with it’s first official release in 2006.

Varnish is now developed and maintained under a separate company (https://www.varnish-cache.org). It is open source (two-clause BSD license) and used among many large web applications including VG.
(more…)


How to make Ubuntu play nice with VMware

DevOps

ubuntuvmware

Here at VG a large amount of our services are deployed on virtualized servers in our VMware cluster. A majority of these servers are running CentOS, but from time to time there is a need for other distributions, like Ubuntu.

In this short write up we will go through a couple of things we find necessary to do to bring Ubuntu up to speed in a VMware environment. (more…)


Make your stuff look better – in 3 easy steps!

CSS

Many developers dread that final part of a project when they have coded up a brilliant piece of work and all that is left is making it look presentable. Unfortunately, it’s repeatedly proven that technical brilliance is easily overlooked unless it looks half decent and preferrably a bit unique. And while the trustworthy Twitter Bootstrap takes care of the first, it fails badly on the latter. Sometimes it might also be a bit superfluous to pull out an entire framework for a small piece of work.

So here’s a short, simple primer – in three simple steps – that can help you make your project look a bit more presentable without the need of an entire library.
(more…)


TechShock – A tech meetup

TechShock

The developers here at VG have been talking about wanting to arrange a meetup for quite some time. At some point we sat down and tried to nail down the details of how we would arrange it. We created a group on Meetup and about a month later, on September 25th, we held our very first meetup event. It was a big success. A month later, we did our second event – focusing on the mobile application discussion around native/hybrid and web solutions. On Wednesday, December 4th, we’re arranging our third event. Title: Modern PHP. (more…)