I recently wanted to integrate WordPress, Magento and a bespoke Zend application to work together.

For the main part, this was easy. I put the Magento installation into a seperate folder, and the WordPress folder into a seperate and then wrapped the lot in a Zend Application.

The .htaccess file looked much like any usual Zend Application.

This sits at the main httpdocs level, knowing that the application .htaccess files would pick up for their tasks.

That’s pretty much it. Unless you want to use sessions.

The main issue here, is sharing the Magento session. It likes to store session information in its own folder. Whereas PHP would usually store session information in something like /tmp/, Magento stores it in it’s application directory /var/session/.

In order to grab session information within the Zend app for example, we need something like the following:

This causes Zend to use the same directory as Magento, and also merges the session data with Magento at the same time by merging with the $_COOKIE. We put this code in the bootstrap to make sure it’s set early on and doesn’t interfere with anything within Zend, and we make Zend do the work so that we don’t interfere with anything Magento is offering.

I’ll be putting up a longer post, with details on how to integrate with WordPress on the Branded3.com blog soon!

Edit: This post is now up! View it here http://www.branded3.com/b3labs/zend-framework-magento-and-wordpress-sitting-in-a-tree/

Image Credit: blmiers2