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

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

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

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

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

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

Friday, October 15, 2010

Population outburst


Hi, this is my first blog post. Hence bear me! Dont think that I am up with yet another school topic, yes it is a school topic but it is a topic which decides the future of planet earth.

We are of a nation with 1.2 billion people. Right now we have second largest population in the world and we are expected to overtake China in 2030 (Yuppieeeee! :P). We have 2.4% of world's land mass yet we account for a scorching 17.5% of the world's population!

There are lots of problems the world is facing right now, almost all of them are directly or indirectly dependent on Population crisis. For problems such as: Pollution, Deforestation, Global warming, Poverty, crisis for food and fresh water, un-employment, depletion of fossil fuel, threat to last of wildlife and its habitat etc etc etc . . . population can be accounted for!

It can be summed rightly that the root causes for above are: Population and Education. If people are properly educated about those problems they can be solved, I guess. Population crisis can be eradicated with proper education.

So how can the population explosion be controlled? Simple, DISOBEY the current government scheme "Hum do, hamare do". Yes guys, its time to put that phrase into trash. Its time for: "One family, one child".

Pretty simple math will explain how the latter will be useful:

1. Say if 2 families have 2 children each, they will in-turn contribute to 2 families in future. This is never ending, the tree remains the same, unless a pair decide to have one more child, the tree expands even more!

2. On the other hand, if each family had only one child, 4 families will contribute 2 families to the next generation. They in-turn will yield only 1 family in the future.

"Hum do, Hamare do":


"One family, one child":

Thus it is evident that the new scheme must be voluntarily accepted by the citizens of this country. We must not wait for the government to impose rules on us, it is our responsibility to resolve the problem since we have understood it. The choice we make now will surely decide our fate in the future.

Some of the eminent thinkers and naturalists have identified problems derived out of population crisis:

Sir David Attenborough says: “The human population can no longer be allowed to grow in the same old uncontrolled way. If we do not take charge of our population size, then nature will do it for us and it is the poor people of the world who will suffer most.”

There is a series called "Life of Mammals" by BBC. In the last episode "Food for thought", sir David Attenborough describes the fall of highly civilized Mayan culture and its people. The cause for this fall being, surprisingly - Population:

The domestication of cattle led to farms and then to villages. With vastly increased food supplies, the number of human beings sophisticated advances in architecture, mathematics & astronomy. However the Maya couldnt sustain their population - and Attenborough warns we may be precariously close to a similar catastrophe: "Three and a half million years separate the individual who left these footprints in the sands of Africa from the one who left them on the moon! A mere blink in the eye of evolution. Using his burgeoning intelligence, this most successful of all mammals has exploited the environment to produce food for an ever-increasing population. In-spite of disasters when civilizations have over reached themselves, that process has continued, indeed accelerated, even today. Now mankind is looking for food not just on this planet but on others. Perhaps the time has now come to put that process into reverse. Instead of controlling the environment for the benefit of the population, perhaps its time we control the population to allow the survival of the environment".

This is what Carl Sagan has to say:
"At present there are about 6 billion humans. In 40 years, if the doubling time stays constant, there will be 12 billion; in 80 years, 24 billion; in 120 years, 48 billion. ... But few believe the Earth can support so many people. Because of the power of this exponential increase, dealing with global poverty now will be much cheaper and much more humane, it seems, than whatever solutions will be available to us many decades hence. Our job is to bring about a worldwide demographic transition and flatten out that exponential curve—by eliminating grinding poverty, making safe and effective birth control methods widely available, and extending real political power (executive, legislative, judicial, military, and in institutions influencing public opinion) to women. If we fail, some other process, less under our control, will do it for us."

Stress on these parts of the quotes: David Attenborough - "...If we do not take charge of our population size, then nature will do it for us..." and Carl Sagan's - "...If we fail, some other process, less under our control, will do it for us..."

It is evident that the problem will be tackled, but by us or nature? The choice is ours!

I found a humorous statement somewhere while surfing, check it out:

What If 'Hum Do, Hamare Do' Had Worked?
For starters, the population of India today, based on crude birth and death rates, would have been 610 million. But, then, Sachin Tendulkar would not have happened...

This holds good for "One family, one child" policy too, now should I re-consider the post? :P