Ruby 1.9.2 installation from source on Ubuntu

by Pawel Barcik

There are easier ways to install most up to date version of Ruby on your system , for e.g. RVM or rbenv but if you want to have full control over what are you installing because it will be your production system, then this post will show you how to do this.

To install Ruby from source you need to install some dependencies first

Continue reading →

Symfony2 pagination with controller as a service and data sorting

by Pawel Barcik

Symfony2 doesn't provide any good pagination tools out of the box so to solve this quite important problem I have created my own solution.

I needed to be able to paginate data based on requested page and per_page parameters through GET and POST requests. Second important thing was to be able to sort displayed data by id, title, etc.

I could have created some Paginator class but I wanted to be able to tweak each part of the process as I see fit on a per controller basis and I wanted to be able to access necessary functions through very short function calls directly in a controller.

I decided to extend all my controllers with necessary helper functions which would be available across all of them whenever I need to paginate something.

First problem was extending the controllers. Symfony2 docs page shows you how to create controllers in a vary common way, but what it doesn't say is that in this way you won't be able to extend all controllers without running into various problems with access to the service container and Doctrine2 EntityManager which is needed to work with your data.

The solution to above problems is to use controllers as a service which allows you to use class inheritance, interfaces etc. in any way you want.

Application setup

Lets assume the application is configured as follows:

  • bundle is located in src/Foo/DemoBundle
  • all controllers will extend ApplicationController class which extends Symfony\Bundle\FrameworkBundle\Controller\Controller
  • pagination template is located in here src/Foo/DemoBundle/Resources/views/Pagination/pagination.html.twig
  • all necessary twig macros will be stored in here src/Foo/DemoBundle/Resources/views/global_macros.html.twig

Continue reading →

FastCGI php 5.3.6 compilation on Ubuntu 8.04

by Pawel Barcik

In this article I will show you how to compile php 5.3 on Ubuntu 8.04 but it should work in a similar manner on later distributions.



  • added some new dependencies: libicu-dev g++ libmysqlclient-dev

First some dependencies:

apt-get install make gcc autoconf bison re2c libxpm-dev libsasl2-dev libpspell-dev libreadline5-dev libsnmp-dev

#apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev apache2-utils apache2.2-common
apt-get install aspell libaspell-dev libxml2 libsnmp-base libsnmp15 libxml2-dev
apt-get install libbz2-dev libzip-dev libzip1 zlib1g zlib1g-dev
apt-get install curl libcurl4-openssl-dev libcurl3 libcurl3-gnutls
apt-get install libc-client-dev libfreetype6 libfreetype6-dev
apt-get install libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev
apt-get install libmcrypt-dev libmcrypt4 libtidy-dev libxslt1-dev libicu-dev g++ libmysqlclient-dev

# for /usr/bin/apxs2
#aptitude install apache2-threaded-dev apache2-utils apache2.2-common

aptitude install libicu-dev libicu38

#aptitude install mysql-server-core-5.0 

#aptitude install mysql-common mysql-server mysql-server-5.0 mysql-client mysql-client-5.0 mysql-server-core-5.0 

I have commented out the the dependencies which are needed for compiling the apache2 module because in this post I want to show you how to get the the php5-cgi binary which is a bit tricky because you can't compile all binaries at once and you need to know which options to disable to get the CGI .

No we are going to need the php's source code:

Continue reading →