Monthly Archives: January 2015

Yii2 mcrypt php extension required

After installing Yii2, most of the time you can get this type of error message:

Yii2 uses PHP extension mcrypt which supports a wide variety of block algorithms such as DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and GOST in CBC, OFB, CFB and ECB cipher modes. Additionally, it supports RC6 and IDEA which are considered “non-free”. CFB/OFB are 8bit by default.

To solve this problem type the following command in your terminal:

after running the above commands, you are all set.

Happy Coding!

Ubuntu How to display PHP error messages

While working on Ubuntu, by default PHP error messages are disabled and while developing web application we need to enable debugging mode to better understand the error instead of blank screen.

Following are the step to solve this:

Step – 1:

Open terminal and type the following command to open the php.ini file

Step – 2:

Find the following line

and replace with following line

Step – 3:

Now restart the Apache so that the new changes will take effect, enter the following command in your terminal

now, you will be able to see PHP error messages in your PHP scripts.

Happy Coding!

URL Rewriting using ISAPI_rewrite 2 for WordPress

Recently, I was working on a WordPress website for a client. For the development version I hosted that website on personal website as a sub-domain and after completing the website, client asked me to upload the site to his domain in-order to make it live.

When I checked the client hosting server: it was a windows based hosting with IIS 6 having PHP support. So when I transferred all of the data to this server… later I found out that except the main home page, no other page was working… I as was getting IIS 404 error page. The reason for this was: I used WordPress permalinks to make the url understandable. Upon contacting the hosting provider they said: I have to use httpd.ini to make this work.

After spending some quality time, finally I have solved the problem and below is the httpd.ini code for WordPress:


I hope, this will help you save your time and focus your energy on more important things 🙂

Happy Coding

How to upload a file in Yii2

If you have worked in Yii1.1 then you will know how to upload a file in Yii, to upload the file in Yii2 is almost the same.

In this article we will be using table named contact with few attributes (id, name, pic) and for this we will go step by step:

Step 1:

Setup global parameter for fileUploadUrl in params array of your configuration file, such as:

Step 2:

Create a Controller that will handle file upload:


Step 3:

To render to View for the file upload form:


Step 4:

Now, set your Model as follows:


with setting all these, now you will be able to upload file, save it in upload folder and save the file name in database table filed.

Happy Coding!