Category Archives: PHP

[Solved] Error executing git commit in phpstorm

I thought Git and Phpstorm would work out of the box with minimal configuration. I pointed Git.exe in phpstorm and tried committing a file. To my surprise, I got the following error always.

example is taken from web:

"Error executing git commit --only -F /private/var/folders/bs/zfry67p51_gflf6hqgzplv2xt80189/T/git-commit-msg-5921808149812071312.txt --author=dsedlacek -- web/js/definitions/jquery.d.ts web/js/libs/handlebars-v1.3.0.js web/css/icon...."

And after poking around for a while. I kept git.exe in windows global PATH variable and Phpstorm started working smoothly with Git :).

Solution: Set full path to git.exe to windows environment PATH variable.

Right click on computer > Properties > Advanced system settings > Goto advanced tab then click on “environment variables” > In system variables find the PATH variable edit it and at the end put semicolon and then append the full path to git.exe.

Hope this helps the needy soul :)

[Solved] How to deploy php app to heroku from windows

I am fulltime linux user and parttime windows user. Lately I have started working with windows for some project stuffs. I found windows quite frustating and limited to what linux provided me. Well it’s all personal feelings. I always hated unnecessary installations of extra applications for the same tools which most of the linux distributions provides us out of the box. For e.g. ssh-keygen. To emulate the most of the linux command we need to install cygwin.

I was working on a facebook application and had to deploy it to heroku. I could do this with few commands in ubuntu which already come with those commands preinstalled. I had to do nothing, just push and push as I had already added my SSH keys in heroku settings.

Basic walkthrough on how one can deploy the heroku app using git Bash shell.

To carry out this process you must have git bash shell installed. Download git for windows and install it.
Git Download Link

Download Heroku toolbelt for windows, Download Link for Heorku

Once downloaded install the heroku toolbelt. After installation is complete, you can set heroku path to the environment variable.

c:\set path=%path%;C:\Program Files (x86)\Heroku\bin;

Now start the Git bash shell.
Git bash shell

Note:We installed git bash shell because it already comes with ssh-keygen which is required to generate pair of our keys.

1. Generate SSH Keys for windows

$ ssh-keygen -t rsa

When asked for

Enter file to which to save the key(/c/Users/user/.ssh/id_rsa):
just hit enter then enter your password, re-enter your password.

See the screenshot below:
Generate SSH Keys for windows

You have successfully generated ssh keys and has been saved in location supplied above.

Now, you have to use those SSH keys with heroku. To do this first copy the contents of id_rsa.pub file exactly as it is. You will find this file in C:\Users\user\.ssh\, if you haven’t changed the default folder location while creating ssh keys shown above.

Now, Go to your heroku dashboard, scroll down under section SSH Keys, Click in Add new SSH Key, paste contents of id_rsa.pub here. Then click in Add key. You have successfully added your public key to heroku. Now is the time to test our key.

Also see the screenshot below:
Heroku SSH keys

Upload ssh keys to heroku

$ heroku keys:add

Try to login to heroku use the command shown below, Since we have already added heroku to path. This should work.

$ heroku login

See the screenshot below:
heroku login

If we are using heroku login for the first time, it looks for ssh keys and since we have already created SSH keys and have also added it to heroku, this should work as expected and give us authentication successfull message. That’s it.

2. Add heroku remote repository to the project

$ heroku git:remote -a survey2email-sam

See screenshot below:
Add git repository to heroku

3. After adding heroku remote confirm it. To confirm it use the following command.

$ git remote -v

git remote -v

4. Now push code commits

$ git push heroku master

Enter password that you used to create SSH Key pairs. Wait for a while, heroku is working on your requesting.
After few seconds/minutes depending on your sources you will be shown feedback what is going on. Now you can feel relaxed and have cup of tea.

Push git repository to heroku

Congratulations. You have successfully deployed your PHP app to heroku.

I have skipped some steps assuming that you have basic familiarity with git. The above command assumes that you have already added, commited your codes to repository and want to deploy them to heroku.

If you find any difficulty in following the walkthrough drop your questions in comment box below.

[Solved] Codeigniter session expires frequently

I was working in a Codeigniter project and when I hit refresh button (F5) continuously, My application session was expiring frequently. I googled for a while and found the simple solution.

A solution is to increase the amount of time for the session_time_to_update in codeigniter config.

Since I won’t be updating session frequently. I am setting it to much higher values such as 86400 (24 hours).

Here is my settings

$config['sess_cookie_name']	= 'app_session';
$config['sess_expiration']	= 0;
$config['sess_expire_on_close']	= FALSE;
$config['sess_encrypt_cookie']	= FALSE;
$config['sess_use_database']	= TRUE;
$config['sess_table_name']	= 'app_sessions';
$config['sess_match_ip']	= FALSE;
$config['sess_match_useragent']	= TRUE;
$config['sess_time_to_update']	= 86400; // 24 hours

Since then I haven’t got this problem.

Reference : http://ellislab.com/forums/viewthread/182755/#864970

Introduction to drush for drupal development

What is drush ?

Drush is very popular and useful tool for drupal developers. It provides us shell access to the drupal commands and functions which otherwise had to be accessed using the menus provided in the drupal administration. It helps us to enable/disable modules, installs  dependency modules automatically, manage users, permissions etc. For complete feature of drush browse this page.

In short drush is just like other command line tools :) Sweet.

Drush official page is http://drupal.org/project/drush

drush was initially created for linux/mac environments however it can be run on windows as well.

Drush can be installed in linux,mac and windows. But runs faster in linux, at least I felt so personally.

For Ubuntu
Type the following command

$ sudo apt-get install drush

when asked enter your computers password and hit enter

For Other Linux Distributions
Download the source from drush source extract it and then follow the readme.txt.

Actually you download the shell script for the drush and make it executable for the current user by adding the path to drush in environment variable so that it’s always available for the execution. To use Drush from the command line, you’ll need a CLI-mode capable PHP binary version 5.2 or greater.

For Windows
1. Visit http://drush.ws/drush_windows_installer
2. Download Drush 5.8 Windows Installer
3. Follow the Installation Guide

How to verify I you have installed drush successfully or not ?
– execute command ‘drush version’ at command prompt, it should show you output something like “drush verison 5.8”. It means you have successfully configured drush.

How to use drush ?
– cd into the root folder of your drupal project. For eg. my drupal project is in /media/BACKUP/htdocs/news/
– then I use “cd /media/BACKUP/htdocs/news”

Then to clear the cache I use “drush cc all” and response is

‘all’ cache was cleared in /media/BACKUP/htdocs/news#default                           [success]

You can try with other commands like “drush en module-name”

Hope this gives your short introduction on drush usage for drupal development. If you want to know more information about this then drop comments. Thanks.