PHP 5.4 Install php-intl extension on centos 5 with latest ICU data

When i moved my Symfony project to VPS, the problem is missing php-intl because i have installed PHP from Remi repository (php 5.4.11). I will show you how can we fix it.

Install ICU version 4+ to meet symfony’s requirements by compile it from source

I choose ICU version

tar -xvf icu4c-4_8_1_1-src.tgz
cd icu/source/
./runConfigureICU Linux
make install

If Everything is OK, you are ready to next step

Compile php-intl extension from source
Let’s choose the same php version with your self, my case is PHP 5.4.11

tar -xvf php-5.4.11.tar.bz2
cd php-5.4.11/ext/intl
./configure --enable-intl
make install

Everything is OK, we have at /usr/lib64/php/modules/

Edit php.ini to load extension

Restart php-fpm

/etc/init.d/php-fpm restart


Symfony 2: Injecting service as dependency into doctrine repository

To do that, you must declare repository as a service and inject services which you need into it.

        class: MY\EntityBundle\Entity\CitiesRepository
        arguments: [MYEntityBundle:Cities]
        factory_service: doctrine.orm.entity_manager
        factory_method: getRepository
            - [ setCanonicalizer, [ @util.canonicalizer ] ]

The repository class:

namespace MY\EntityBundle\Entity;

use Doctrine\ORM\EntityRepository;
use FOS\UserBundle\Util\CanonicalizerInterface;

 * CitiesRepository
class CitiesRepository extends EntityRepository
     * @var CanonicalizerInterface $canonicalizer
    protected $canonicalizer;

    public function setCanonicalizer(CanonicalizerInterface $canonicalizer)
        $this->canonicalizer = $canonicalizer;

    public function getCanonicalizer()
        return $this->canonicalizer;

    public function saveFromString($cityName, Countries $country)
        $city = $this->findOneBy(
            array('name' => $this->canonicalizer->canonicalize($cityName))
        if (!$city) {
            $city = new Cities();

        return $city;


$city = $this->get('cities_repository')->saveFromString(
            'Ho Chi Minh',
            new Countries('VN', 'Vietnam')

Symfony 2 redefine form_row for horizontal form in bootstrap support validation style

Override form_row block in your twig template as follow:

{% form_theme signup _self %}
{% block form_row %}
    {% spaceless %}
        <div class="control-group{% if errors|length > 0 %} error{% endif %}">
            {{ form_label(form, '', { 'label_attr': {'class': 'control-label'} }) }}
            <div class="controls">
                {{ form_widget(form) }}
                {% if is defined %}
                    <span class="help-block">{{ }}</span>
                {% endif %}
            {{ form_errors(form) }}
    {% endspaceless %}
{% endblock form_row %}
{% block form_errors %}
    {% spaceless %}
        {% if errors|length > 0 %}
            <div class="controls">
                {% for error in errors %}
                    <span class="help-block">{{ error.messagePluralization is null
                    ? error.messageTemplate|trans(error.messageParameters, 'validators')
                    : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators') }}</span>
                {% endfor %}
        {% endif %}
    {% endspaceless %}
{% endblock form_errors %}


{{ form_widget(signup) }}

Use Memcache for Session handler on Symfony 2.1


session_memcache_port: 11211
session_memcache_prefix: sess
session_memcache_expire: 3600


        class: Memcache
             - [ addServer, [ %session_memcache_host%, %session_memcache_port% ]]

        class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler
        arguments: [ @session.memcache, { prefix: %session_memcache_prefix%, expiretime: %session_memcache_expire% } ]

        handler_id: session.handler.memcache

[Ubuntu] PHP 5.4.x and gearman troubleshooting

When upgraded to PHP 5.4.x, you may have an error:
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/20100525/’ – /usr/lib/php5/20100525/ undefined symbol: gearman_job_error in Unknown on line 0

[Resolve] Update your gearmand server to the latest version

Remove current gearman from packages manager
sudo apt-get remove gearman gearman-job-server

Install lastest version (now gearmand-1.1.1.tar.gz )
sudo apt-get install libboost-program-options-dev libboost-all-dev libevent-dev cloog-ppl
tar -xvf gearmand-1.1.1.tar.gz && cd gearmand-1.1.1/
sudo make install

Run gearman
gearmand -d

Check version
gearadmin --server-version

Start gearman at boot up: init script

Centos 5.8 install your own git server

Install dependencies

yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel

Install from source

tar -xzvf git- 
cd git-
make install

Check install:

git --version

Create new Test repo:

useradd git
cd /home/git
mkdir test-repo
cd test-repo
git init
cd ../
git clone --bare ./test-repo/ test-repo.git

Add your public key to authorize

cd /home/git
mkdir .ssh
touch .ssh/authorized_keys
# import your public key into authorized_keys
chown -R git.git ./*

Now you can clone your test-repo and then pull, push

git link: git@server_ip:test-repo.git

Codeigniter hook: combine master page and auto load view

Get source at:

How to use?

When use this hook. you don’t need to load view manually by hand, just doing what are in your controller codes

Old way:
public function index()
// your code

New way:
public function index()
// your code

The view of action will auto located at path /application/views/{controller}/{method}.php if exists

Note: the view only will be locate if there is no output from controller ($this->output->set_output() won’t be call in controller codes)

will be continue…

Centos 6.2: Compile PHP 5.4.2 from source

Before installation start, make sure you have already installed web server such as Apache, Nginx… and Mysql server

Install command:


yum -y install libmcrypt libmhash openssl-devel bzip2-devel libxml2-devel libjpeg-devel libpng-devel libmcrypt libmcrypt-devel pcre pcre-devel curl-devel freetype-devel gmp-devel mysql-devel ncurses-devel pspell-devel net-snmp-devel



tar -xvf mhash- && cd mhash- && ./configure && make && make install  && cd ../



tar -xvf mcrypt-2.6.8.tar.gz && cd mcrypt-2.6.8 && ./configure && make && make install && cd ../

Download php source from, extract it


cd php-5.4.x

./configure \

--with-apxs2=/usr/sbin/apxs \

--with-config-file-path=/etc \

--enable-intl \

--with-mysql \

--with-mysqli \

--with-pdo-mysql \

--enable-sockets \

--with-zlib \

--with-bz2 \

--with-gd \

--with-jpeg-dir \

--with-png-dir \

--enable-ftp \

--enable-mbstring  \

--with-mcrypt \

--with-mhash \

--with-pear \

--with-curl \

--with-openssl \

--with-libxml-dir \

--enable-exif \

--with-freetype-dir \

--enable-soap \

--with-tidy \