PHP Money Library – safe money calculations

The basic question is: why should we use this type of library and why not use the float type instead? The problem is that computers are not able (and have never been) to handle floating point values with real accuracy. While for some insignificant data this should not be a problem, in the case of recalculating the amounts of money-related transactions, it is already a serious concern. This library frees us from issues related to currency operations, storing them (or just preparing for it), adding or converting. All this without fear about lack of precision.

Continue reading “PHP Money Library – safe money calculations”

Some useful convert (ImageMagick) commands

I must sometimes modify images and PDF documents in PHP. Prepare them to display after user upload, prepare for database, fix dimensions or many other things. Of course we can use native PHP functions, but it’s very slow. Better option is to use external libs like convert (ImageMagick) and Ghostscript.  Today I have some useful convert commands – it’s “list to remember” for me, but maybe also you will find someting nice? This post is short, because I paste only commands and very short description.

Continue reading “Some useful convert (ImageMagick) commands”

PHP/Mongo – Using JOIN in queries

I’ve written one post about MongoDB and PHP about creating nested set model in this database, but there is another interesting topic: using JOINs in mongo queries. Sorry, wh… what? Joining tables in non-relational database? Yes, it’s possible and we can do this to collect much more data in only one, but more complicated query. Let’s start to see how we can achieve this.

Continue reading “PHP/Mongo – Using JOIN in queries”

Zend Framework – create custom controller plugin

Few weekes ago I wrote about custom view plugins in Zend Framework. It’s great solution to separate and re-use code for our templates, build simple functions for menus, thumbnails etc. But… what about similar situation in controller? Yes, it’s possible to use view helpers in controllers, but it isn’t good. Creating controller plugin is much better option and we can do that in Zend Framework. Let’s try.

Continue reading “Zend Framework – create custom controller plugin”