API Service versioning best practices URL headersWhat happens if you need to make changes to your API?

If you’re making additions to the API – e.g., adding services or adding fields to your services – you likely don’t need to do anything more to notify users than to tell them about the changes.

But what happens if you need to make a change that will affect users?

  • Adding authentication
  • Adding authorization rules
  • Removing a service
  • Removing or renaming fields inside services

Such changes as these impact your existing users. At times like these, you need to create a new version of your API.

But how do you do that? (more…)

Tagged with: , , ,

Symfony2 configuration file for custom bundleWhen I build apps or add new functionality to Symfony2 I build it into a separate bundle, thus trying to keep the structure modular which is generally a good practice as everyone knows. Keeping all parts of the bundle together makes it easy to maintain and also easy to change the configurations as they reside in same place as the code itself.

In this post I’ll show you how to make Symfony2 core discover your config.yml and services files defined in your custom bundle.

Create new bundle

First let’s create a new bundle that we’ll use as a demo. Run following command in the terminal: (more…)

Tagged with: , , ,

magnolia cms javaProblem

I am using Magnolia CMS 5.4 and I want to build a module that will render some content of a page and expose it over REST API. The task is simple but not sure how to approach it and/or where to start.

I want my module to generate partial template or an area of a template for a given reference, let’s say that is “header”. I need to render the header template/area get the HTML and return that as a response to another system.


First thing the rendering works based on different renderers and those could be JCR, plain text or Freemarker renderer. In Magnolia those are decided and used in RenderingEngine and the implementation: DefaultRenderingEngine. The rendering engine will allow you to render a whole page node which is one step closer to what I am trying to achieve. So let’s see how could this be done:

Tagged with: , , , ,

PECL out of memory with Composer and LaravelLaravel is great framework and I quite enjoy how it’s structured and how it works. In version 4 it was migrated from bundles to using Composer for dependency injection which is great and fits well in my daily routine on building apps also follows standards promoted by the PHP community in general.

In my application I was planning to add MongoDB support as first I’d like to improve the performance and second my data structure is perfect for this purpose, furthermore I want to improve my NoSQL skillset.

In this article I’ll describe the steps that I followed on installing the MongoDB provider, the problems that I’ve faced and final solutions and small tricks I used to make all work. (more…)

Tagged with: , , , , ,

pass console command parameters to bash alias command- like hammer bashes a nailI use BASH aliases extensively throughout my DEV environments and it saves me a lot of time. One specific I use is “cdv” that’s shorthand for CD to VirtualHosts which in most cases could be as simple as /var/www or in some cases could be very long path, especially on shared DEV environments like /var/www/dev/vhosts/mylongusername. (more…)

Tagged with: , , , , ,

Magento export customer emails from ordersMagento export

Every now and then I am asked by different clients if I can export specific customer data, most often people need emails of their customers to use for newsletters or other types of marketing campaigns. There are two different ways to approach the problem either get all orders and get the customer email or any other related details that might be needed or you can use the customer collection which will give you all unique records for customers.

Setup magento API access


Tagged with: , , , ,

Custom error handler for Laravel 4

Custom error handler for Laravel

I build API service for a mobile application and I faced a problem with the error reporting with Laravel.

Laravel is awesome framework and is great for RESTful application or building API that’s why it’s my first choice.

But I had one problem, my API should produce only JSON and my application can consume only JSON. So HTML error pages are pointless and needless for me. I had a specific case where a PHP error was causing problems but I also wanted to handle all PHP and display them appropriately for my app. Here is the solution: (more…)

Tagged with: , , , ,

Consistent dates in PHP?

Consistent dates in PHP

It’s really interesting how small changes in core PHP functionality could break whole website and take hours to find the cause of the bug.

I am building website which takes some use of dates, stored in MySQL database as Date format for simplicity

Those dates are optional fields in my application and sometimes they have Zero Date format: ‘0000-00-00‘ which works perfectly on my development environment. Locally I am using PHP 5.3.4 not latest but allows me to spot any backward compatibility issues and probably it’s more laziness for not upgrading than any other sophisticated reason. Anyhow on production I run PHP 5.3.24 and so far everything has been just OK, running smoothly with no issues.

Tagged with: , , ,

Install PHP mcrypt linuxIn this quick tip I’ll show you how to install the PHP extensionmcrypt. This is needed for Magento to run properly otherwise you’ll get an error like:
[cc type=”text” escaped=”true”]Fatal error: Call to undefined function mcrypt_create_iv() in lib/Varien/Crypt/Mcrypt.php on line 64[/cc]

Tagged with: ,

Clean dirty html with sqlI had a problem with client’s data that was saved as HTML in the database and I needed it in plain format. Many would say this is very inefficient way of doing it but sometimes desperate time call for desperate measures. And here is my solution to the problem: (more…)

Tagged with: , ,