Symfony2: Installation

The official installation doc is

As a best practice, don’t install symfony in MAC or Windows, install in Linux and use Linux for development because you will be using Linux for hosting.

For consistency in development, develop in virtual machine. The spec of the virtual machine should be the same as the production server. The best way to do it is to use vagrant.

In this example, we will create a ficticious project called SongBird. First of all, we need to create a portable and consistent development environment so that we speak the same language. This is also important if you decide to outsource the development in the future. Next we need a tool like puppet to configure automate software configuration.

To get started, let’s get this symfony repo –¬†

git clone
vagrant up

This will take a long time… most of the alerts you see in the screen is harmless. this is a once off setup. Enter root password when prompted.

According to the doc, you can choose a number of ways to install symfony, most people chose the composer method. Don’t use composer or manually download, install the symfony command line instead.

vagrant ssh
# you are now in the virtual machine
sudo curl -LsS -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony

To create a new project call “songbird” using the long term support version,

cd /vagrant
symfony new songbird lts
cd songbird
sed "s/''/'',''/g" -i web/app_dev.php
# check that all requirements met
php app/check.php
# you should see that the config has passed

In your parent host, we need to add get to be pointing to the vm. add this to your host file.

In your parent, Test your site by going to

If you see the word “Homepage”, everything is good.

Now let us commit everything before we proceed.

git init .
git add .
git commit -m"init commit"

When is hardcoding good?

Hardcoding is always seen as a bad practice. It makes the code inflexible. For example, making the code aware of the environment itself is a good thing so that we can reuse the code and avoid code duplication. Here, we are trying to copy a file to a user directory. is better than If this … Continue reading

Important CPANEL logs

These cpanel logs are important when troubleshooting: apache: /usr/local/apache/logs/ exim, ssh and others: /var/log/ cpanel: /usr/local/cpanel/logs/

Speeding up vagrant virtualbox disk access

Virtualbox driver is very slow. You can google about this all over the internet. There are 2 ways to speed up vagrant disk access using nfs, one way is to use vagrant-bindfs plugin and another way is the traditional way to change permissions in vm. This method outlines the later. shutdown vagrant using “vagrant halt” … Continue reading

Disable postfix to send email to outside world

disabling postfix to send email to outside world is important especially in development environment. you don’t want client to receive emails when you are testing in the dev environment. Unless software is using external smtp server to send email, you can simply update postfix config ( relayhost = and restart postfix

Custom ajax call in woocommerce

sometimes you need to update database via ajax. wordpress has tools to make it easy. Well not that easy… here for example, we want to create a link that when clicked, automatically change the order status of a woocommerce order and insert some notes. In the template, Note that we have to use nonce to … Continue reading

Creating custom pages in woocommerce

what if you want to have a custom page in woocommerce? For example a page called abc under my-account best way is to use shortcodes. Create a new page under my-account, ie my-account/abc and put in the shortcode [abc_shortcode] then in functions.php now you need to create the abc.php file which can contain anything

Symfony: Quick way to change bundle name

You have generated a new bundle under src/Oldnamespace/oldbundle and decided to change the bundle name or move it to a new name space. Symfony doesn’t provide any tools to do that. Sounds like a tedious job… There is no short cut to this solution but some Bash scripting can save your lots of time. Use … Continue reading

Installing phpmyadmin in hhvm

when installing phpmyadmin under hhvm and nginx especially, you might get an error like so: “Error during session start; please check your PHP and/or webserver log file and configure your PHP installation properly” this is due to hhvm settings, got /etc/hhvm/php.ini and comment out all the php options like so: ; php options ;session.save_handler = … Continue reading

CPanel exim unrouteable address

if exim is showing up errors like “unrouteable address”, it means that exim is trying to send mail locally. If your local dns is borked, you will get this error. The fix is to fix your local mx entry. If you have configured an external dns server, then you should go to DNS functions -> … Continue reading