Saturday, September 14, 2013

Setup for Debugging PHP code on Mountain Lion OS X with XAMPP and PhpStorm

I faced hard time configuring system to debug PHP code on localhost. Thought of archiving it before I forget! I started out with this very useful gist: https://gist.github.com/makangus/3816880 but there were few changes in the context of Mountain lion and XAMPP.

Xdebug is shipped along with Mountain Lion, so the new MacOSX users need not download it. We have to configure the system to use it.

1. Configuring the php.ini file to enable Xdebug: Usually we find the php.ini file in '/etc/php.ini'. But if you are running XAMPP to create a local webserver, make sure that you edit the php.ini file in the location: '/Applications/XAMPP/xamppfiles/etc/php.ini'. Add the following lines at the end of your php.ini file:

[Xdebug]
zend_extension=/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

Please note the location of xdebug.so file. The Mountain Lion is shipped with Xdebug and it's default location is "/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so" but I suppose when we install XAMPP, it moves a copy over for itself in the location "/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so". This could be confirmed by checking the phpinfo's extension folder location:


All set, now run this php script in your local webserver to confirm that Xdebug is setup:

<?php phpinfo(); ?>

Now to you should have a dedicated Xdebug section in the phpinfo:




 2. Now we need to setup the PhpStorm with the root folder of the PHP scripts which we want to debug. It's easy to create a project with all the files of your root folder containing the PHP code:



Next comes configuring the project for the PHP web application:

Go to Menu Run > Edit Configuration

Next, click the '+' button to add a new PHP web application:


Now configure the root folder for your PHP resources in this newly created Web Application:


Now setup the server for this project:


This is the setup for PHPStorm. Now, if you could open your index.php in the navigator and place a breakpoint you can confirm it. When you click on the 'debug' menu, a URL is triggered in default web browser something like:

http://localhost/your_web_folder/cms/?XDEBUG_SESSION_START=18601
PHPStorm supposedly uses this Xdebug session for debugging purpose. If you want to test and debug webservices, that is possible using the same debug session:

http://localhost/your_web_folder/cms/web_service_api_endpoint/node.xml?XDEBUG_SESSION_START=18601

All this done saying, now I have to start debugging and resolve my actual problem!

PS: I am a beginner and am eager to learn new things, there maybe some errors in this post and also I may have gone wrong in my understanding. I would welcome people correcting me and giving their views. If you have questions I will try my best to address them.

Friday, January 25, 2013

Story of my dream - 2


Dreams occur when one is not too tired, we would remember them only if we aren't too tired and sleep peacefully.

It was one such day when I was not too tired and I hit the bed early.

It so happened that the dream began with me and my sister walking on the pavement. It was near the dairy circle and she insisted me to buy an ice cream. The moment she demanded one, an ice cream shop out of no where appeared! But we had to cover a distance of 50 mts. to it.

While going towards it our eyes caught a guy coming towards us from the opposite side. He was the kind of person who made a shiver run up spine! He was tall & dark, with shaggy hairs and the looks would give you hint that he was a rogue. But in my case it was no hint, my sixth sense told me that he was absolutely not a gentleman and his intentions were not good! I was very sure that this guy was a thief and had come to rob us of our money and valuables.

I had a plan, I slipped my hand into the pocket and dialled "100" without anyone noticing. My sixth sense was right! He came right upto me, pulled out a knife and started demanding money. Myself and my sister were quite in a shock. I knew I had dialled for police and somehow had to buy more time and importantly let them know what's happening and where we were!

Since I knew that by now police would have received the call, I started shouting "I know you are a thief, you are demanding us for money! But I have bought none since my home is near Diary circle and am at diary circle right now. I Did not bring any money as I don't have any need now!". I was sure now that my message was delivered, my stress on "Diary circle" would have been good enough for the police to send in for quick help!

All I had to do now was to buy more time. I told the rowdy that we have no money, he didn't believe us. Well this was good for me as I needed more time. I took out the wallet and he found some money, I now was surprisingly bargaining with this guy! Trying to convince him that he only take half and leave us remaining as we were in dire need of it. My main intention, again, buy some time for police to arrive. Negotiations were on, this guy was stubborn and time was being spent. I was wondering what took so long for help to arrive. I decided to switch to "Plan B".

Plan B - This was just one guy, with a knife in his right hand. Grip his wrist, twist his arms, hold his neck and suffocate him. Snatch his knife out of his hands.

I gathered enough courage and the actions of plan B began to flow. Exactly as it was supposed to happen. In moments I had the knife now. Turned out that this fellow had a plan B too! I loosened the grip on him when I snatched his knife, he whistled and there were 2 guys at his service with knives in their hands! We could not have fought all three. We were outnumbered, and hence I promptly returned back the knife to its rightful owner. My sister was a shocked spectator all throughout this. A few people had gathered around, more to fulfil their curiosity than to help. Typical people mentality where they just watch and do nothing. I was still wondering what took so long for police to arrive.

I was still trying to negotiate with all three guys and then the police jeep came in, they arrested the 3 robbers and went off!

Now, the people around started discussing about who had called the police. After a while few of them came forward and asked "How did the police come? None of us called for help!". Then I explained everything which had happened, of how I suspected that the first guy was a thief and how I dialled for help without anyone observing. People praised high for my presence of mind and prediction.

Everybody left off from the scene.

I suddenly realised that I had never got a chance to disconnect the call! I took my iPhone out from my pocket and saw that I had actually called "108"!

The End!

Sunday, January 20, 2013

Story of my dream - 1


It was the first week after I purchased my new iPhone and I was downloading and investigating a lot of applications. The new world of my iPhone was just amazing! It was getting late one night so I decided to just look at one more app.  It just so happened to be a ghostly one! 

I headed on to bed and slept very peacefully. I didn't know my dream from reality when I ended up in a haunted house. My mission for the next hour or so, get out alive!

So it began! I was in a room which only had a couch and a table in front of it. The room was brightly lit and there was an adjacent room equally lit too, both rooms were separated by a big transparent glass wall. The light on in the other room started to dim. This made the glass reflect more light from my room. As the reflection got clearer, I saw that there were ghosts sitting besides on both sides of me! I ran for my life.

I ran through a corridor while the ghostly fog tried to attack me from opposite sides! I dodged one and then the next until I made it through the corridor without being attacked by a single one of them! 

I wanted to arouse myself from this scary ghost dream, but all forces were against me, the dream went on!

While I was looking for a way out of the haunted house, I discovered a small baby crying on the floor. Wondering who would have abandoned such an adorable small baby, I picked her up. I wanted to take her out of the haunted house along with me. I held her over my shoulder and after a few steps, I was unable to move. Something was pulling me back. I gathered up enough courage to satisfy my curiosity to look back. It was a shocker! To my amazement, the baby's arms stretched to the exact place where I had picked her up! Better late than never, I realized that I had picked up a ghost! I threw her off my shoulder and I started running again.

I found an exit unguarded by any of the ghosts, quickly I made my way out of the house. Sigh that was a relief.

Sounds like a happy ending, isn't it?

But wait a minute, I was checking myself to see if I was all fine. I happened to check my pockets, oh no! I had left my iPhone inside the haunted house!!!

The shock of my own stupidity woke me up. The night ended with my roommate's amazement and their laughter filling the silence at midnight!

Monday, November 21, 2011

garvavyAtako ninage

ಗರ್ವವ್ಯಾತಕೋ ನಿನಗೆ ಪಾಮರ ಮನುಜ
ಧರೆಯೊಳಗೆ ಕುರುಪತಿಗೆ ಸರಿಯೆನ್ನಬಹುದೆ?

ಬಲದಲ್ಲಿ ಹಲಧರನೆ? ಛಲದಲ್ಲಿ ರಾವಣನೆ?
ಕುಲದಲ್ಲಿ ವಸಿಷ್ಠ ಗೌತಮನೇನೊ ನೀನು?
ನೆಲೆಯಲ್ಲಿ ಭೃಗು ಮುನಿಯೆ? ನೇಮದಲ್ಲಿ ಗಾಂಗೆಯನೆ?
ಒಲುಮೆಯಲಿ ವಾಲ್ಮಿಕಿ ಏನೋ ನೀನು?

ಹಠದಲ್ಲಿ ಪ್ರಹ್ಲಾದನೆ? ದೃಢದಲ್ಲಿ ಧೃವರಾಯನೆ?
ಷಠ್ಠರೊಳಗೆ ವಿಷ್ವಾಮಿತ್ರನು ಏನೊ ನೀನು?
ವಿಠ್ಠರೊಳಗೆ ಮನ್ಮಥನೆ? ವೀರರೊಳ್ ಪಾರ್ಥನೆ?
ಕುಟಿಲತನದಲ್ಲಿ ಶಕುನಿ ಏನು ನೀನು?

ದಾನದಲ್ಲಿ ಕರ್ಣನೆ? ಗಾನದಲ್ಲಿ ನಾರದನೆ?
ಜ್ಞಾನದಲ್ಲಿ ವ್ಯಾಸ ಶುಖ ಮುನಿ ಏನೊ ನೀನು?
ದೀನರಕ್ಷಕ ನಮ್ಮ ಪರಂದರ ವಿಠ್ಠಲನ
ಧ್ಯಾನದಲ್ಲಿ ಇದ್ದು ಭವ ನೀಗು ಮನುಜ!

- ಶ್ರೀ ಪುರಂದರ ದಾಸ