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’);

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.