PHPStorm Debugging Won’t Start

Problem: PHPStorm will let you debug something running on a server running XDebug. But it never connects

Context: Server is a Bitnami Magento stack running on VMWare. Configured XDebug by commenting out the lines at end of php.ini

Solution: The problem is the line:

xdebug.remote_host=127.0.0.1

This is the default line added by Bitnami to php.ini. But if you are connecting remotely, even from the same machine outside the VM, you have to put the address of the machine you are debugging from there.

Find your IP address. The easiest way is to go to the command line and type:

ifconfig

Then look for IP addresses in there. It is probably the one on en0.

You can also look at the php variable:

 _SERVER[“REMOTE_ADDR”]

Which you can get from a phpInfo() call.

Turning On Magento Logging

Problem: Magento does not output log files

Context: New Magento Install

Solution: Turn them on in Admin

In Magento admin go to System->Advanced:Developer->Log Setting.

Set Enabled to YES.

Still nothing will happen if there are no log messages. The log directory won’t exist, nor the log files until the first time something is output to the log. Magento doesn’t really log much, so you should log something.

To make sure it works add this line to the end of index.php

Mage::log(‘Does this work’);

Why I Leased An Office

So I could look down at Abilene. 🙂
Northern Office View
For the past year I’ve been doing software consulting from my home office. This has a lot of advantages, but recently I decided I needed to get an office outside of my house. Now that I’m sitting in my new office I thought I’d write a blog post on why I did it.

Developing a Practice

I’ve been reading a couple of books in the last few weeks that influenced my decision. One was Manage Your Day-to-Day, edited by Jocelyn Glei one of the editors at Behance. It is a collection of essays from different “gurus” on how to be a freelancer better. One chapter is a Q&A with Seth Godin. His answer to the question, “What’s the hardest part about getting a daily routine right?” is what got me thinking office.

“The strategy is to have a practice, and what it means to have a practice is to regularly and reliably do the work in a habitual way.”

I’ve also been reading, The Power of Habit by Charles Duhigg. One of the points of the book is that habits are how we live our lives. Even really complicated behaviors are often habits. Duhigg breaks down a habit into Cue-Routine-Reward. Something triggers the habit (Cue), our brains go into autopilot, and we just do the routine. This means if you want to consistently do something, you need a cue. One kind of cue is a change of environment. This is the beginning of what Godin calls a Practice for work.

My office is my new cue for working. When I get to the office it is to work. To create. Even now, during the first time I’ve been to the office when it was mine, I’m working. I’m writing a blog post. Even though I’ll have to go home to post it because my Internet isn’t hooked up yet, I’m working.

(This is related to my new found distinctions between obstacles and excuses, which I’ll write about another time.)

Isolation

When you work for yourself and have no employees or coworkers, you have very little face to face interaction with other people. Add to that I’m are new in town and it can get lonely. Actually it really isn’t lonely, it’s more stir crazy. There have been a number of days in the last couple of weeks where I’ve gotten up early in the morning and gone to bed late at night and never came in contact with another human being (my wife’s been out of town 11 of the last 14 days.) That’s just not good for you, even if you’re an introvert.

Getting an office at least forces me out of the house.

Division of Work and Home

Working from home means work can never start and it can never end.

It is easy to do just one more thing around the house before you start working, or to wash some dishes during a programming break. Those dishes turn into cleaning the whole house and you’ve spent a couple of productive hours doing the wrong thing.

The opposite happens too. If I’ve got a project due for a client and I sit still for a few minutes at the house doing nothing, I’ll feel the need to go work. Doesn’t matter if I worked all day on the project, because it’s just a walk down the hall to my computer. It is easy to keep working. I also have insomnia, and if I wake up at 3 AM one of the things that plagues me out of bed is work that needs to be done.

Having an office means work is in one place, and home is in another.

Other Reasons

There are a few other small things that make this office better than my house. Surprising to me, these are the kind of quantitative reasons most people would use to justify the expense.

Distraction I love my wife and have missed her dearly when she’s been gone these last couple of weeks, but she’d been home one day when her legitimate interruptions of my work started to bug me. When I get in the zone programming, any little thing can pull me out. Then it can take 15 minutes to an hour to get back in the groove. Having my own office will lower that.

The internet should be blazing fast. One of Abilene’s business Internet providers is in the building and they have a special deal for tenants. They’ll hook you into there fiber network and you get 20-30 megabits down and 10 or so upload.

Office rent in Abilene is dirt cheap. I’m renting a 500+ square ft office for under $400/month. It includes utilities and office cleaning.

Ego. It adds a little cache to be in the tallest building in Abilene. (Twenty floors if you were wondering) Also adds some legitimacy to some clients to have a “real” office in a high rise.

And, being on the 8th floor, I can look down on Abilene.

View from window near elevators.

View from window near elevators.

Connecting to a Local VM With a Domain

Problem: When running a VMWare virtual machine, the machine has an IP you can connect to, but that is hard to remember and subject to change.

Context: VMWare running the Bitnami Magento image.

Solution:

Configure the local machine’s host file to know the VMs ip. Now you can create SFTP bookmarks with the domain name instead of the ip.

Steps:

1. Get the VMs IP address

On the VM machine type:

ifconfig

The IP address with be in the first section, and probably start with 10.0.x.x

2. On OSX change the host file.

The file is at:

/private/etc/hosts

Open it for editing. This needs to be done as root. BBEdit will ask you to authenticate.

Add a new line at the bottom

10.0.1.74 bitnami-vm.local

Remember whatever domain you choose will over ride the rest of the internet, so I picked a .local, which might cause problems with bonjure.

3. Flush your local DNS cache

In terminal type:

dscacheutil -flushcache

Making Products Show Up on the Home Page of a New Magento Install

Problem: In a new install of magento you can create products but they don’t show on the home page.

Context: New magento install

Solution:

To make things show up on your home page, you have to go to CMS->Pages and find,  “Home Page” and click to edit. Then add

{{block type=”catalog/product_list” category_id=”XX” template=”catalog/product/list.phtml”}}

where XX is the category ID you want shown on the front page. You can get the category ID in Catalog->Manage Category then click the category you want on the left. The ID will be shown next to the name.

Also go to Catalog->Manage Products->YourProduct->Inventory and make sure you set your product to be in stock. Also that the quantity is not 0.

If you can’t set that. Go to System->Configuration->Catalog:Inventory->Product Stock Options and set “Manage Stock” to No.

Mounting A Shared Folder in VMWare Under Linux

Problem: VMWare Fusion allows you to set up shared folders for a VM in its preferences. Once you have it enabled, where is the mount?

Context: VMWare Fusion 5, Bitnamit Magento Image, Ubunto

Solution:

Mounting Shared Folders in a Linux Guest

After you have enabled a shared folder, you can mount one or more directories or subdirectories in the shared folder to any location in the file system in addition to the default location of /mnt/hgfs.

Use the mount command to mount all shares, one share, or a subdirectory within a share to any location in the file system.

Mount Command Syntax

Command Description
mount -t vmhgfs .host:/ /home/user1/shares Mounts all shares to
 /home/user1/shares
mount -t vmhgfs .host:/foo /tmp/foo Mounts the share named 
foo to /tmp/foo
mount -t vmhgfs .host:/foo/bar /var/lib/bar Mounts the subdirectory bar 
within the share foo to /var/lib/bar

 

You can use VMware-specific options in addition to the standard mount syntax. For usage information for the host-guest file system options, type the command /sbin/mount.vmhgfs -h.

When you install VMware Tools, an entry is made to etc/fstab to specify the location of shared folders. You can edit this file to change or add entries. For example, to auto-mount at startup, edit /etc/fstab and add the line .host :/ /mnt/hgfs vmhgfs defaults 0 0.

The VMware Tools services script loads a driver that performs the mount. If the mount fails, a message appears regarding mounting HGFS shares.

Note

The mount can fail if shared folders are disabled or if the share does not exist. You are not prompted to run the VMware Tools vmware-config-tools.pl configuration program again.

Development Problems and Solutions

I’ve taken a new approach to documentation during a development process. There have been a number of times – especially when dealing with Magento – that I’ve had a problem doing something, figured it out and then a few weeks later I have the same problem again and can’t remember how to solve it. Often these are those problems that take hours to trial and error and google searching to figure out.

So I’ve come up with a solution. Now when I have one of these problems and solve it, I create a new Evernote note with a specific format and tag detailing how I solved it.

Every one of these notes starts with three headings, Problem:, Context:, Solution:. Then I fill in the information for each. The whole note gets a tag “problem/solution”. Now when I run into that problem again, I can easily find the note on how to fix it.

I’ve decided that since I often have to search and search online for the solutions to these problems, that I’d start making them blog posts here on Reactuate as well. So you can look forward a lot of development related posts in the very near future.

How To Find the Private Key For the Delicious API

I’d like to write a python script that looked at my Delicious Bookmarks and checks to see if they are dead links. This is possible because Delicious has an API. And you can just ask for what you want by asking for a specific URL.

That works fine as long as you don’t want your private bookmarks. If you want them, you have to:

{key} = a security key for the feed, which can be found via the page associated with the feed (eg. inbox, network or bookmarks). Allows visibilty to otherwise private data.

But there is no explanation of how you find the key. It says via the “page associated with the feed”. But it’s not. Not anymore, because Delicious changed its look and in the process hid its RSS feeds.

As an aside, when did RSS because pariah? Google drops Readers, Delicious hides its RSS feeds. What’s up?

But you can still find the needed private key by signing in to your account and going to http://feeds.delicious.com/{username}/

Over on the right side, you’ll see something like the image at the right: Delicious Sidebar

The URL for the “Private” link has your key in it.

You can get it by right clicking and using “Copy Link” or your browser’s equivalent. The private key is that big bunch of letters and numbers after the “?private=”. Just put it on your request URL the same way.

BTW: this key may change if you change your password.