I was playing with PHP the other day and was trying to fetch and rename 1000s of files I have stored locally on my machine. Seemingly PHP isn’t the best language to that operation Python or even BASH could do the job though it was nice to give it a try. So this is what I came up, simple and straightforward.
Read more ›
Dates as a concept are seamingly simple and straight forward. Though in programming world those could be rather complex starting from format, representation, time zones, machine default configuration going through different calendars and date manipulations.
In this post I won’t to give a quick tip on handling dates in an application that I am building. It will be short post, I promise.
Read more ›
Posted in API
, Small Tips
Tagged with: API
Polymorphic type handling based on JSON property
Building an API that supports inheritance could be quite crucial. Imagine the case where you want to have an endpoint that stores a profile data for a given provider and that provider could be your main website or any 3rd party platform that can provide the data. We might have a base
Profile class which in our case would be abstract class with firstName and lastName fields and an abstract method to provide the name of the actual profile provider
You can do all of that quite easily with few Jackson annotations, for polymorphic types, on the base class and on the children that extend the base class. No more words here is an example: Read more ›
Many people go for different solutions and sometimes overcomplicate their applciation with message queues like ActiveMQ, RabbitMQ and other options out there. Though this is yet another part in the application architecture that would require maintenance and support and it’s also a possible failiure point.
There are good reasons to use this approach but in most cases you can get through with normal in-memmory queue with multi-threading. Read more ›
What 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? Read more ›
When 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
services files defined in your custom bundle.
Create new bundle
First let’s create a new bundla that we’ll use as a demo. Run following command in the terminal: Read more ›
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:
Read more ›
Laravel 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. Read more ›
I 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. Read more ›